Embedding QDialog into QML
-
I have created a QML with a "toolbar" on top (just a couple of rectangles with different colours). It also contains a MouseArea which slides the toolbar in and out (hides / unhides it). This is working fine.
The rest of the page is filled with a Grid. Is it possible to embed a QDialog which I've created with Qt Widgets into that Grid? The QDialog contains a QTabDialog with QFormLayouts on each page.I know that it would be good to rewrite everything in QML but this would be too much effort. Also creating this animation which slides in / out the toolbar on top and resizes the rest of the page automatically is not that easy in C++ (or at least I don't know how to do it). That's why I would like to combine both technologies (even though they should not be mixed if it can be avoided).
Thank you for your help!
-
You should be able to use QGraphicsProxyWidget to embed a QWidget-based object. QDeclarativeViewer is just a sub-class of QGraphicsView after all - at least in QtQuick 1.x
-
I'm sorry, QGraphicsProxyWidget should be avoided.
I've done it the other way around now. I created my toolbar in QML and the rest in C++.
The QDeclarativeView and the QTabWidget are contained in a QVBoxLayout. My problem is that the cell of the QDeclarativeView is not properly resized when the toolbar is sliding out.
The margins of the layout are 0 and also the spacing is 0.
I have tried a couple of size policies. In the Qt Designer I can see that the height of the QDeclarativeView is 69 (even though it should resize to 35). I don't know how I can change it so that only the part which I want to see in the end is visible.Here is a screenshot of the shown toolbar: !http://dl.dropbox.com/u/2346027/Toolbar_Shown.PNG(Toolbar shown)!
Here is a screenshot of the hidden toolbar: !http://dl.dropbox.com/u/2346027/Toolbar_Hidden.PNG(Toolbar hidden)!
And here is a video of the animation I've created in QML (the colours look a bit weird in the video):
"Video of the Toolbar":http://dl.dropbox.com/u/2346027/Toolbar.aviI've also tried to add the toolbar with setMenuWidget() to the MainWindow, but I've got the same problem there.
Can you maybe tell me how I can set the correct spacings or size policies so that the embedded QML is resized correctly (only the grey bar with the dark grey button should be visible in the end, without any spacings on top or between the bar and the tab widget).
-
[quote author="saho" date="1320390313"]I'm sorry, QGraphicsProxyWidget should be avoided.
[/quote]I agree that it should be used sparingly but if it's just for one widget then it should be fine.
[quote author="saho" date="1320390313"]
I've done it the other way around now. I created my toolbar in QML and the rest in C++.
[/quote]OK that is also perfectly reasonable. I'll have a look at your other questions when I have a little more time than right now.