1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#include "mainwindow.h"
//////////////////
// Constructeur //
//////////////////
MainWindow::MainWindow (QWidget *parent) : QMainWindow(parent) {
this->initComponents (parent);
this->initConnections ();
}
/////////////////
// Destructeur //
/////////////////
MainWindow::~MainWindow () {
}
//////////////
// Méthodes //
//////////////
void MainWindow::initComponents (QWidget *parent) {
// Window Initialisation
this->setWindowTitle (" - QComix");
this->resize (1024, 768);
// Menus Initilisation
menuFile = this->menuBar ()->addMenu ("&File");
menuEdit = this->menuBar ()->addMenu ("&Edit");
menuView = this->menuBar ()->addMenu ("&View");
menuHelp = this->menuBar ()->addMenu ("Help");
actionOpen = this->menuFile->addAction ("&Open");
actionQuit = this->menuFile->addAction ("&Quit");
actionAboutQt = this->menuHelp->addAction ("About &Qt");
actionQuit->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
// Widget Initialisation
label = new QLabel;
label->setText ("This is a try ! Does it work ?");
label->show ();
mainGridLayout = new QGridLayout;
mainGridLayout->addWidget (label, 0, 0);
this->setLayout (mainGridLayout);
}
void MainWindow::initConnections () {
// Menus
connect (actionQuit, SIGNAL (triggered ()), qApp, SLOT (quit ()));
connect (actionAboutQt, SIGNAL (triggered ()), qApp, SLOT (aboutQt ()));
connect (actionOpen, SIGNAL (triggered ()), this, SLOT (openDialog ()));
}
void MainWindow::openDialog () {
// QString file = QFileDialog::getOpenFileName(this, "Open a file", QString(), "Pictures (*.png *.gif *.jpg *.jpeg)");
// label.setPixmap (QPixmap (file));
} |
Partager