qt - How to embed QML toolbar and menubar into QMainWindow -


i using qwt library plot data. seems not possible embed qwidget qml quick 2. so, decided create qmainwindow main window , create toolbar , menubar using quick controls. how should embed qml toolbar , menubar qmainwindow?

you should create qml applicationwindow qml menubar , toolbar

main.qml

applicationwindow {     visible: false     menubar: menubar {         menu {             title: "edit"             menuitem {                 text: "cut"             }         }     }     toolbar: toolbar {         row {             anchors.fill: parent             toolbutton {                 iconsource: "1.png"             }         }     } } 

main.cpp

qapplication app(argc, argv); qqmlapplicationengine engine; engine.load(qurl(qstringliteral("qrc:///main.qml"))); 

then pointer applicationwindow

qwindow *qmlwindow = qobject_cast<qwindow*>(engine.rootobjects().at(0)); 

create window container, using qwidget::createwindowcontainer

qwidget *container = qwidget::createwindowcontainer(qmlwindow); container->setminimumsize(qmlwindow->size()); 

and place container top of widget

qwidget *widget = new qwidget(); qgridlayout *grid = new qgridlayout(widget); grid->addwidget(container,0,0); grid->addwidget(new qpushbutton(widget),1,0); widget->show(); 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -