QPushButton and QToolButton are both QAbstractButtons, with the former being more general purpose than the latter which is better suited to a Command Pattern usage. QMenuBar and QMenu is a hierarchical presentation of QActions rendered in a familiar UI fashion. (Either button type can have a context menu also) The range of options represents the range of common UI widgets on the various platforms Qt started on.

Checkable does work with an action in the QMenuBar. The QAction is marked checked and any QToolButton or QMenu items attached to that action are rendered "checked" when the item in the QMenuBar is clicked. The QMenuBar does not expect a menu to be on/off and consequently does not render a distinct "checked" look (this you could override if you really wanted). If you want a permanently opened menu then the tearoff function is available. Really though it sounds like you want a tool bar not a menu.

Qt Code:
  1. #include <QtGui>
  2.  
  3. class MainWindow: public QMainWindow {
  4. Q_OBJECT
  5. public:
  6. explicit MainWindow(QWidget *p = 0): QMainWindow(p) {
  7. QAction *a = new QAction("Futz About", this);
  8. a->setToolTip("I will futz about on command");
  9. a->setCheckable(true);
  10. connect(a, SIGNAL(triggered()), SLOT(futzAbout()));
  11.  
  12. QMenuBar *mb = menuBar();
  13. mb->addAction(a); // <<<< try clicking this guy and watch the others change
  14.  
  15. QMenu *menu = new QMenu("A Menu", this);
  16. menu->addAction(a);
  17. mb->addMenu(menu);
  18.  
  19. QPushButton *pb = new QPushButton("Futz QPushButton", this);
  20. connect(pb, SIGNAL(clicked()), a, SLOT(trigger()));
  21.  
  22. QToolButton *tb = new QToolButton(this);
  23. tb->setDefaultAction(a);
  24.  
  25. QWidget *content = new QWidget(this);
  26. QVBoxLayout *layout = new QVBoxLayout(content);
  27. layout->addWidget(pb);
  28. layout->addWidget(tb);
  29. setCentralWidget(content);
  30. }
  31.  
  32. private slots:
  33. void futzAbout() {
  34. qDebug() << Q_FUNC_INFO;
  35. }
  36. };
  37.  
  38. int main(int argc, char **argv) {
  39. QApplication app(argc, argv);
  40. MainWindow w;
  41. w.show();
  42. return app.exec();
  43. }
  44. #include "main.moc"
To copy to clipboard, switch view to plain text mode