jeudi 19 septembre 2019

Label on QToolBar, possible?

Is is possible to have labels in a QToolBar? Something like the green text I draw on top of the app screenshot.

enter image description here

QApplication a(argc, argv);
QMainWindow *w = new QMainWindow;

QToolBar *barA = new QToolBar;
barA->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);

QAction *actOnA = new QAction("OnA");
actOnA->setIcon(QIcon("../../../on.png"));
barA->addAction(actOnA);
QAction *actOffA = new QAction("OffA");
actOffA->setIcon(QIcon("../../../off.png"));
barA->addAction(actOffA);
w->addToolBar(barA);

QToolBar *barB = new QToolBar;
barB->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);

QAction *actOnB = new QAction("OnB");
actOnB->setIcon(QIcon("../../../on.png"));
barB->addAction(actOnB);
QAction *actOffB = new QAction("OffB");
actOffB->setIcon(QIcon("../../../off.png"));
barB->addAction(actOffB);
w->addToolBar(barB);

w->show();
return a.exec();

I think I saw similar labels in a Microsoft MFC project.

Aucun commentaire:

Enregistrer un commentaire