Hello,
I'm trying to make a button in the menu bar that allows to display a sub window of type QDockWidget.
The problem is that the slot that displays the window can't have arguments because the signal 'triggered' of QAction doesn't have any.
Actually, I didn't find a predefined slot that allows to do what I want so I tried to make my own slot display() and inside it there's only a show().
The problem is that I can't choose which window I want to display because the signal and the slot must have the same number of arguments.
Here is my code.
I'm trying to implement a function that allows to display 'palette' after it has been accidently closed by the user.
#include "FenPrincipale.h"
FenPrincipale::FenPrincipale()
{
//creation of the menu
QMenu *menuFichier
= menuBar
()->addMenu
("&Fichier");
QAction *actionQuitter
= menuFichier
->addAction
("&Quitter");
actionQuitter
->setIcon
(QIcon("quitter.png"));
QMenu *menuEdition
= menuBar
()->addMenu
("&Edition");
QMenu *menuAffichage
= menuBar
()->addMenu
("&Affichage");
// Création de la barre d'outils
QToolBar *toolBarFichier
= addToolBar
("Fichier");
toolBarFichier->addAction(actionQuitter);
toolBarFichier->addSeparator();
toolBarFichier->addWidget(choixPolice);
// Creation of the docks
addDockWidget(Qt::LeftDockWidgetArea, dock);
dock->setWidget(contenuDock);
dockLayout->addWidget(crayon);
dockLayout->addWidget(pinceau);
dockLayout->addWidget(feutre);
dockLayout->addWidget(labelEpaisseur);
dockLayout->addWidget(epaisseur);
contenuDock->setLayout(dockLayout);
// Création of the central zone
setCentralWidget(centralzone);
connect(actionQuitter, SIGNAL(triggered()), qApp, SLOT(quit()));
}
#include "FenPrincipale.h"
FenPrincipale::FenPrincipale()
{
//creation of the menu
QMenu *menuFichier = menuBar()->addMenu("&Fichier");
QAction *actionQuitter = menuFichier->addAction("&Quitter");
actionQuitter->setShortcut(QKeySequence("Ctrl+Q"));
actionQuitter->setIcon(QIcon("quitter.png"));
QMenu *menuEdition = menuBar()->addMenu("&Edition");
QMenu *menuAffichage = menuBar()->addMenu("&Affichage");
// Création de la barre d'outils
QToolBar *toolBarFichier = addToolBar("Fichier");
toolBarFichier->addAction(actionQuitter);
toolBarFichier->addSeparator();
QFontComboBox *choixPolice = new QFontComboBox;
toolBarFichier->addWidget(choixPolice);
// Creation of the docks
QDockWidget *dock = new QDockWidget("Palette", this);
addDockWidget(Qt::LeftDockWidgetArea, dock);
QWidget *contenuDock = new QWidget;
dock->setWidget(contenuDock);
QPushButton *crayon = new QPushButton("Crayon");
QPushButton *pinceau = new QPushButton("Pinceau");
QPushButton *feutre = new QPushButton("Feutre");
QLabel *labelEpaisseur = new QLabel("Epaisseur :");
QSpinBox *epaisseur = new QSpinBox;
QVBoxLayout *dockLayout = new QVBoxLayout;
dockLayout->addWidget(crayon);
dockLayout->addWidget(pinceau);
dockLayout->addWidget(feutre);
dockLayout->addWidget(labelEpaisseur);
dockLayout->addWidget(epaisseur);
contenuDock->setLayout(dockLayout);
// Création of the central zone
QWidget *centralzone = new QWidget;
setCentralWidget(centralzone);
connect(actionQuitter, SIGNAL(triggered()), qApp, SLOT(quit()));
}
To copy to clipboard, switch view to plain text mode
I hope you have understood me, if not please ask for further details.
Thanks
Bookmarks