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. What is the "parent" for a QWidget used in QML?
Forum Updated to NodeBB v4.3 + New Features

What is the "parent" for a QWidget used in QML?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 768 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.
  • D Offline
    D Offline
    drmhkelley
    wrote on last edited by
    #1

    A have a Qt widget, say myQWidg, which I'd like to repurpose for use in a QML app. Without myQWidg, the QML app works just fine. When used as a Qt widget outside of QML, the myQWidg works just fine.

    However, when I use myQWidg in the QML app, app fails with the error

    "QWIdget: Cannot create a QWidget without QApplication"

    As near as I can tell, what fails is a custom popup dialog, say myQDialog, that is part of myQWidg. The above error seems to be generated by the first use of myQDialog. The relevant code is

    myQDialog temp;
    temp.doSometing(someparameter)

    I think error is triggered by the second, not the first statement.

    As near as I can tell, myQtDialog is created with a NULL parent, but myQtDialog requires a QApplication as parent or ancestor.

    Hence, my question about parenting. I think things would start working if my creation of myQWidg in QML gave it the QML parent widget.

    Any suggestions?

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

      Hi,

      That's unrelated. Your QML app is likely using QGuiApplication. Change that to QApplication if you want to mix it with widgets.

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

      1 Reply Last reply
      0
      • D Offline
        D Offline
        drmhkelley
        wrote on last edited by
        #3

        Thanks!! Not sure how I would have figured that out without your pointer.

        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