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. "Floating" popups/dialogs
Forum Updated to NodeBB v4.3 + New Features

"Floating" popups/dialogs

Scheduled Pinned Locked Moved Solved QML and Qt Quick
13 Posts 5 Posters 2.3k 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.
  • B Offline
    B Offline
    Bob64
    wrote on last edited by
    #1

    I know that the normal QML way is that Popup and Dialog are effectively drawn inside rectangles that are completely within the main window area. This is often fine but for more complex content I have often wished for the more traditional desktop app approach where the dialog is a floating window that can be moved around freely and possibly resized - basically not being constrained by the bounds of the main window.

    Is the best/only way to achieve this to create my own popup component using a Window? Is there anything wrong in doing this other than it is a bit non-standard in terms of QML paradigms?

    Thanks.

    1 Reply Last reply
    0
    • E Offline
      E Offline
      ebatsin
      wrote on last edited by
      #4

      Best way is to simply use a Window. You can customize it to your needs (remove the title bar, etc.).

      import QtQuick 2.15
      import QtQuick.Window 2.15
      
      ApplicationWindow {
      	id: root
      	visible : true
      
      	width: 400
      	height: 300
      
      	Window {
      		visible: true
      		modality: Qt.ApplicationModal // prevent user interacting with parent window
      		transientParent: root // indicates that this window acts as a modal for its parent window
      	}
      }
      
      1 Reply Last reply
      2
      • A Offline
        A Offline
        Allon
        wrote on last edited by
        #2

        Hi,
        I do not quite understand. Do you want to have a floating popup completely outside of you application? Could you do a quick sketch so that I can visualise it?
        Thanks,
        Emmanuel

        1 Reply Last reply
        0
        • fcarneyF Offline
          fcarneyF Offline
          fcarney
          wrote on last edited by
          #3

          If want anything to exist outside your main window then you need to use one of the Window types. I know about 2 types, there may be more.

          C++ is a perfectly valid school of magic.

          1 Reply Last reply
          0
          • E Offline
            E Offline
            ebatsin
            wrote on last edited by
            #4

            Best way is to simply use a Window. You can customize it to your needs (remove the title bar, etc.).

            import QtQuick 2.15
            import QtQuick.Window 2.15
            
            ApplicationWindow {
            	id: root
            	visible : true
            
            	width: 400
            	height: 300
            
            	Window {
            		visible: true
            		modality: Qt.ApplicationModal // prevent user interacting with parent window
            		transientParent: root // indicates that this window acts as a modal for its parent window
            	}
            }
            
            1 Reply Last reply
            2
            • B Offline
              B Offline
              Bob64
              wrote on last edited by
              #5

              Thanks. I assumed Window must be the way to go but I have struggled to find much discussion about this and so wondered if what I wanted to do was fundamentally at odds with QML paradigms.

              A 1 Reply Last reply
              0
              • B Bob64

                Thanks. I assumed Window must be the way to go but I have struggled to find much discussion about this and so wondered if what I wanted to do was fundamentally at odds with QML paradigms.

                A Offline
                A Offline
                Allon
                wrote on last edited by
                #6

                @Bob64 Hi do not quite understand the problem :( You can place your popup wherever you want using x an y coordinates.
                If you parent it to the main window you can do whatever you want regarding positioning?
                Regards,
                Emmanuel

                B 1 Reply Last reply
                0
                • A Allon

                  @Bob64 Hi do not quite understand the problem :( You can place your popup wherever you want using x an y coordinates.
                  If you parent it to the main window you can do whatever you want regarding positioning?
                  Regards,
                  Emmanuel

                  B Offline
                  B Offline
                  Bob64
                  wrote on last edited by Bob64
                  #7

                  @Allon Apologies for not replying sooner. I have not had access to my PC for a few days and wanted to post a couple of images.

                  The basic issue is that the default QML way does not allow a popup menu or a dialog to extend outside of the rectangle of the main window. Here are a couple of examples where this would be completely natural behaviour in a normal desktop interface:

                  explorer.jpg

                  notepad.jpg

                  Sure it is possible to set the x,y position to mitigate this somewhat but it still does not necessarily provide a convenient solution. To be honest, I am more concerned by dialogs than popups - particularly the use case where the dialog provides some sort of tool for dealing with more complex input as in the second image above. Cases where it is convenient for the user to be able to move the tool out of the way, resize it and so on.

                  1 Reply Last reply
                  0
                  • E Offline
                    E Offline
                    ebatsin
                    wrote on last edited by
                    #8

                    If the idea is to use it for "short lifespan" windows, you can also use Dialog: https://doc.qt.io/qt-5/qml-qtquick-controls2-dialog.html

                    Depending on your use case, it can be better than Window.

                    B 1 Reply Last reply
                    0
                    • E ebatsin

                      If the idea is to use it for "short lifespan" windows, you can also use Dialog: https://doc.qt.io/qt-5/qml-qtquick-controls2-dialog.html

                      Depending on your use case, it can be better than Window.

                      B Offline
                      B Offline
                      Bob64
                      wrote on last edited by
                      #9

                      @ebatsin Well this gets to the crux of my question. I am aware of Dialog but my question arises precisely from the observation that for some use cases it is fairly useless. It's just a rectangle embedded at a static position in the main window. The user cannot resize it or move it outside the boundary of the main window. In fact the user can't move it at all (at least not without what I would assume would be fairly extensive custom code).

                      Perhaps I should ask whether there are any 'gotchas' or issues I should be aware of in using Window?

                      (I suppose a more general question is whether I should be using QML at all for a desktop environment but I think I will reserve that for a separate question at some point.)

                      A GrecKoG 2 Replies Last reply
                      0
                      • B Bob64

                        @ebatsin Well this gets to the crux of my question. I am aware of Dialog but my question arises precisely from the observation that for some use cases it is fairly useless. It's just a rectangle embedded at a static position in the main window. The user cannot resize it or move it outside the boundary of the main window. In fact the user can't move it at all (at least not without what I would assume would be fairly extensive custom code).

                        Perhaps I should ask whether there are any 'gotchas' or issues I should be aware of in using Window?

                        (I suppose a more general question is whether I should be using QML at all for a desktop environment but I think I will reserve that for a separate question at some point.)

                        A Offline
                        A Offline
                        Allon
                        wrote on last edited by
                        #10

                        @Bob64 Hi,
                        It seems here that it can be resized:
                        https://youtu.be/t_UFPXHeiiM?t=413
                        Regards,

                        B 1 Reply Last reply
                        0
                        • B Bob64

                          @ebatsin Well this gets to the crux of my question. I am aware of Dialog but my question arises precisely from the observation that for some use cases it is fairly useless. It's just a rectangle embedded at a static position in the main window. The user cannot resize it or move it outside the boundary of the main window. In fact the user can't move it at all (at least not without what I would assume would be fairly extensive custom code).

                          Perhaps I should ask whether there are any 'gotchas' or issues I should be aware of in using Window?

                          (I suppose a more general question is whether I should be using QML at all for a desktop environment but I think I will reserve that for a separate question at some point.)

                          GrecKoG Offline
                          GrecKoG Offline
                          GrecKo
                          Qt Champions 2018
                          wrote on last edited by
                          #11

                          @Bob64 said in "Floating" popups/dialogs:

                          Perhaps I should ask whether there are any 'gotchas' or issues I should be aware of in using Window?

                          No, there shouldn't be any gotcha. Window is the correct component for your usecase.

                          Note that comments related to your issue has been made in this issue : https://bugreports.qt.io/browse/QTBUG-69790

                          B 1 Reply Last reply
                          1
                          • A Allon

                            @Bob64 Hi,
                            It seems here that it can be resized:
                            https://youtu.be/t_UFPXHeiiM?t=413
                            Regards,

                            B Offline
                            B Offline
                            Bob64
                            wrote on last edited by
                            #12

                            @Allon I think they are using QtQuick 1 dialogs there, which were indeed more like the traditional desktop style that I am talking about. But QtQuick 1 is on its way out so I am not about to start using it. I already have the impending nightmare of what to do about my current use of TreeView.

                            1 Reply Last reply
                            0
                            • GrecKoG GrecKo

                              @Bob64 said in "Floating" popups/dialogs:

                              Perhaps I should ask whether there are any 'gotchas' or issues I should be aware of in using Window?

                              No, there shouldn't be any gotcha. Window is the correct component for your usecase.

                              Note that comments related to your issue has been made in this issue : https://bugreports.qt.io/browse/QTBUG-69790

                              B Offline
                              B Offline
                              Bob64
                              wrote on last edited by
                              #13

                              @GrecKo thank you. That bug report you link to is interesting. In particular the comment here recognises the issue I have been talking about.

                              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