We've got trouble on promoting widgets. When we try to promote QQuickWidget to our class, we can't see QQuickWidget as base class despite other base classes. However sometimes it appears unless doing nothing special. Do you think this is a bug or is there anything to do to solve this problem ?
Asked
Active
Viewed 303 times
0
-
StackOverflow lets you simply paste pictures straight into the question. Do not use any external sites for images. Simply Ctrl-C from the screenshot editor, and Ctrl-V in a chosen point in the question. Remember: questions and answers here are supposed to remain usable for "the foreseeable future". File hosting sites simply drop content after they get bored of you (I'm serious - those links just stop working after a while, Dropbox doesn't host things for eternity, they'd go bankrupt in an afternoon). SO is I'm sure paying good money for imgur to host their image contents. – Kuba hasn't forgotten Monica Aug 25 '20 at 15:55
-
Our company has a protocol that we can't upload project images to anywhere except dropbox. So sorry for that. – Monster Aug 26 '20 at 06:49
-
That also implies then that you can't ask questions on SO with images, because on SO the use of its image hosting is indeed a requirement. You may wish to consider a job change when possible - they won't get any work done or everyone is breaking this rule. Either way it's a sick environment to be in - I'm sorry you find yourself in such a conundrum. The policy is a failed attempt at "IT security": they believe that they can control inadvertent disclosure that way. Gee whiz, guess what: Internet never forgets. The image you posted? It'll stay with us till the end of time for all I know. – Kuba hasn't forgotten Monica Aug 26 '20 at 16:00
1 Answers
1
First of all: do you actually need the Designer to know about the widget being of the QQuickWidget
type? You likely don't, so simply promote it directly from QWidget
. They are all widgets, after all! The only difference a base class makes it that it exposes the derived-class-specific properties for editing using the Designer Ui - that's literally all. If you specifically need to adjust some properties of a QQuickWidget
using the Designer interface, then you can just manually substitute the name inside the .ui
file - it's just an XML file, easy to edit and understand.
Specifically:
sed -e 's/QWidget/QQuickWidget/g' < mypromoted.ui > myfinal.ui
That's all it should take, and you can always verify the results in a text editor.

Kuba hasn't forgotten Monica
- 95,931
- 16
- 151
- 313
-
We are designing our Buttons, Labels etc. on Qml and we are trying to connect C++ classes to our QML files. We don't know the right way to do this. When we promote QQuickWidgets, we are connecting C++ classes to QML files and we can change their values and control events. Are we doing this wrong or is there any easy way to do this ? – Monster Aug 26 '20 at 06:50
-
@Monster Forget about the way you do it now. If you have more than one `QQuickWidget` inside another window, you're pretty much doomed. It wasn't designed to be used that way. You have to have the entire UI window running using QML, and then connection from C++ is relatively easy - Qt has a whole set of *extensive* documentation page about it. Read it: https://doc.qt.io/qt-5/qtqml-cppintegration-overview.html And make sure you follow the links to various sub-pages that focus on details. In a nutshell: you can access any QML object by name from C++ code, using the JS engine context (IIRC). – Kuba hasn't forgotten Monica Aug 26 '20 at 15:58