QMenu in dialog like the one in Mainwindow
Menu in dialog like the one in Mainwindow
Hello, i'm trying to implement a Mainwindow like menu in one of my Dialogs.
Till now i have produced this code
QAction *menuAction; QMenuBar *menuBar = new QMenuBar(this); QMenu *menu = menuBar->addMenu("Utility"); menuAction = menu->addAction("PDF"); connect(menuAction, SIGNAL(triggered()), this , SLOT(pdf_triggered())); menuAction = menu->addAction("Print"); connect(menuAction, SIGNAL(triggered()), this , SLOT(print_triggered()));
This is the result:
As you can see i have been able to insert "PDF" and "Print" options under "Utility" but i would like to create a clickable image+label like i have created in the mainWindow.
Something like this:
Is it possible? Can someone tell me what functions i have to use or point me to an example?
Thanks for the answers and time
@Bruschetta Do you mean you want a tool-bar in your dialog?
Yes, this is the goal i'm trying to achieve
joeQ last edited by
Thak you guys but i already have a QToolbar in my mainwindow and for what i undestood inserting a Qtoolbar into a dialog is not possilbe.
Infact there is no "addToolBar()" method, method that is present in the main window.
I found how to do what i wanted to do.
Here some code for the ones who may have the same "problem"
//into the Dialog QMainWindow * mainWindow = new QMainWindow(); QToolBar * myToolBar = new QToolBar(); myToolBar->setIconSize( QSize( 32, 32 ) ); myToolBar->setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); QPixmap newpix = QPixmap (":/x.png"); myToolBar->addAction(QIcon(newpix), "bla"); mainWindow->addToolBar(myToolBar); QHBoxLayout * layout = new QHBoxLayout(); layout->addWidget(mainWindow); setLayout(layout);