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.
Qt Code:
  1. #include "FenPrincipale.h"
  2.  
  3. FenPrincipale::FenPrincipale()
  4. {
  5. //creation of the menu
  6. QMenu *menuFichier = menuBar()->addMenu("&Fichier");
  7.  
  8. QAction *actionQuitter = menuFichier->addAction("&Quitter");
  9. actionQuitter->setShortcut(QKeySequence("Ctrl+Q"));
  10. actionQuitter->setIcon(QIcon("quitter.png"));
  11.  
  12. QMenu *menuEdition = menuBar()->addMenu("&Edition");
  13. QMenu *menuAffichage = menuBar()->addMenu("&Affichage");
  14.  
  15. // Création de la barre d'outils
  16. QToolBar *toolBarFichier = addToolBar("Fichier");
  17. toolBarFichier->addAction(actionQuitter);
  18. toolBarFichier->addSeparator();
  19. QFontComboBox *choixPolice = new QFontComboBox;
  20. toolBarFichier->addWidget(choixPolice);
  21.  
  22. // Creation of the docks
  23. QDockWidget *dock = new QDockWidget("Palette", this);
  24. addDockWidget(Qt::LeftDockWidgetArea, dock);
  25.  
  26. QWidget *contenuDock = new QWidget;
  27. dock->setWidget(contenuDock);
  28.  
  29. QPushButton *crayon = new QPushButton("Crayon");
  30. QPushButton *pinceau = new QPushButton("Pinceau");
  31. QPushButton *feutre = new QPushButton("Feutre");
  32. QLabel *labelEpaisseur = new QLabel("Epaisseur :");
  33. QSpinBox *epaisseur = new QSpinBox;
  34.  
  35. QVBoxLayout *dockLayout = new QVBoxLayout;
  36. dockLayout->addWidget(crayon);
  37. dockLayout->addWidget(pinceau);
  38. dockLayout->addWidget(feutre);
  39. dockLayout->addWidget(labelEpaisseur);
  40. dockLayout->addWidget(epaisseur);
  41.  
  42. contenuDock->setLayout(dockLayout);
  43.  
  44. // Création of the central zone
  45. QWidget *centralzone = new QWidget;
  46. setCentralWidget(centralzone);
  47.  
  48. connect(actionQuitter, SIGNAL(triggered()), qApp, SLOT(quit()));
  49. }
To copy to clipboard, switch view to plain text mode 




I hope you have understood me, if not please ask for further details.
Thanks