Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QWindow as a parent of QDialog?
Forum Updated to NodeBB v4.3 + New Features

QWindow as a parent of QDialog?

Scheduled Pinned Locked Moved General and Desktop
qwindowqdialog
6 Posts 4 Posters 5.2k Views 2 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.
  • X Offline
    X Offline
    xylosper
    wrote on last edited by
    #1

    The main window of my application is QQuickView which is a subclass of QWindow.
    And, I have a preferences QDialog which contains various controls.
    So, I want to lauch QDialog whose parent is set to QQuickView instance.
    However, there's no constructor to accept QWindow instance as parent in QDialog as you know.
    Is there any way to give QWindow as a parent of QDialog?

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      Hi @xylosper,

      As far as I know, you can't make a QWindow the parent of a QWidget. However, are you willing to implement your dialog using a Dialog QML type?

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      X 1 Reply Last reply
      1
      • JKSHJ JKSH

        Hi @xylosper,

        As far as I know, you can't make a QWindow the parent of a QWidget. However, are you willing to implement your dialog using a Dialog QML type?

        X Offline
        X Offline
        xylosper
        wrote on last edited by
        #3

        @JKSH

        For now, I don't consider that because I'm trying to reuse code which I've written and maintained before Qt 5.
        Also, it contains lots of custom controls and it's really painful to rewrite all of them into QML, especially model/view/delegate parts.

        Thank you for answer.

        1 Reply Last reply
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          You can't mix QWidget in QWindow. You can do other way round.

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          X 1 Reply Last reply
          3
          • dheerendraD dheerendra

            You can't mix QWidget in QWindow. You can do other way round.

            X Offline
            X Offline
            xylosper
            wrote on last edited by
            #5

            @dheerendra

            I'm not trying to 'mix QWidget in QWindow'.
            A dialog never will be mixed with other widget or window.
            It is always top-level widget.
            Setting a parent to dialog means the dialog does not have a separated taskbar item and that's what I want to achieve.

            By the way, I found 'QWindow::setTransientParent()' and I could've achieved my goal by setting a QWindow instance as transient parent of dialog's windowHandle().

            QWindow w;
            w.show();
            QDialog dlg;
            dlg.winId(); // ensure to create native window
            dlg.windowHandle()->setTransientParent(&w);
            dlg.exec();
            
            1 Reply Last reply
            0
            • R Offline
              R Offline
              Rondog
              wrote on last edited by Rondog
              #6

              There is a static function of QWidget that will create a container widget with a QWindow as a parent.
              QWidget* QWidget::createWindowContainer(QWindow *,...)

              Once you have the widget container this can be the parent of any other dialogs or widgets you need to add.

              1 Reply Last reply
              1

              • Login

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