Some questions about put QWidget in QML
Unsolved
QML and Qt Quick
-
I need to put my custom widget which inherit from QWidget into QML as a component, I did this jobs to make it :
- define a class named WidgetComp inherit from QQuickItem(or QObject).
- define a class named MyWidget to make my custom widget.
- declare a MyWidget member varible in class WidgetComp.
- use Q_INVOKABLE to declare a funtion named showWidget() in class WidgetComp. then I can use it to show my custom widget in QML
- register WidgetComp as a QML Componet
just like this:
Now I'm succeed to make it as a component, I can ues it in QML correctly, and it does shown.
But there are some problems exist:- In main.qml: I put WidgetComp in Window, but Window seems not the parent of WidgetComp, because when I set coordinate of WidgetComp , for example: (0, 0). MyWidget shows at the Origin of whole screen, but not the Origin of the Window.
- when I use Android GCC to compile it, setting the coordinate and size(height and width) cames unuseful, it fills full screen at all time whatever how I set those property.
Is there anybody has the experience about this, help me plz, I would be really appreciated!
-
Hi and welcome to devnet,
You can take a look at KDAB's DeclarativeWidgets project. It's library to use QWidgets in QML application.
-
@SGaist said in Some questions about put QWidget in QML:
Hi and welcome to devnet,
You can take a look at KDAB's DeclarativeWidgets project. It's library to use QWidgets in QML application.
thanks very much and I will have a good look