Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Some questions about put QWidget in QML

Some questions about put QWidget in QML

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 683 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • DonationD Offline
    DonationD Offline
    Donation
    wrote on last edited by
    #1

    I need to put my custom widget which inherit from QWidget into QML as a component, I did this jobs to make it :

    1. define a class named WidgetComp inherit from QQuickItem(or QObject).
    2. define a class named MyWidget to make my custom widget.
    3. declare a MyWidget member varible in class WidgetComp.
    4. use Q_INVOKABLE to declare a funtion named showWidget() in class WidgetComp. then I can use it to show my custom widget in QML
    5. register WidgetComp as a QML Componet

    just like this:
    0_1553842261034_WidgetComp.png

    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:

    1. 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.
    2. 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!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You can take a look at KDAB's DeclarativeWidgets project. It's library to use QWidgets in QML application.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      DonationD 2 Replies Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        You can take a look at KDAB's DeclarativeWidgets project. It's library to use QWidgets in QML application.

        DonationD Offline
        DonationD Offline
        Donation
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • SGaistS SGaist

          Hi and welcome to devnet,

          You can take a look at KDAB's DeclarativeWidgets project. It's library to use QWidgets in QML application.

          DonationD Offline
          DonationD Offline
          Donation
          wrote on last edited by
          #4

          @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

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved