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. Opening a dialogue next to main window
Qt 6.11 is out! See what's new in the release blog

Opening a dialogue next to main window

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 3 Posters 1.7k Views 3 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
    BrianE
    wrote on last edited by
    #1

    I am opening a Dialogue to the left of the main window. There is plenty of room and I know how to fix it if there isn't (using a max function) - this is just the bare bones of the problem:

    myDlg->show();
    int xx = x() - myDlg->frameGeometry().width();
    myDlg->move(xx, y());
    

    According to the documentation this ought to cause the right hand edge of the dialogue to be up against the left hand edge of the main window. It isn't! There's a (approx) 15 pixel gap! Is this caused by Win10's 'shadow' nonsense - which I have turned off - or something else? Help would be appreciated.

    raven-worxR 2 Replies Last reply
    0
    • B BrianE

      I am opening a Dialogue to the left of the main window. There is plenty of room and I know how to fix it if there isn't (using a max function) - this is just the bare bones of the problem:

      myDlg->show();
      int xx = x() - myDlg->frameGeometry().width();
      myDlg->move(xx, y());
      

      According to the documentation this ought to cause the right hand edge of the dialogue to be up against the left hand edge of the main window. It isn't! There's a (approx) 15 pixel gap! Is this caused by Win10's 'shadow' nonsense - which I have turned off - or something else? Help would be appreciated.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @BrianE
      use geometry().x()

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • B Offline
        B Offline
        BrianE
        wrote on last edited by
        #3

        I can't! I get an error message:

        D:\Qt Projects\xxx.cpp:280: error: '((MainWindow*)this)->QWidget::geometry' does not have class type
             int xx = geometry.x() - myDlg->frameGeometry().width();
                      ^
        mrjjM 1 Reply Last reply
        0
        • B BrianE

          I can't! I get an error message:

          D:\Qt Projects\xxx.cpp:280: error: '((MainWindow*)this)->QWidget::geometry' does not have class type
               int xx = geometry.x() - myDlg->frameGeometry().width();
                        ^
          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @BrianE said in Opening a dialogue next to main window:

          ((MainWindow*)this)->QWidget::geometry

          That looks odd
          are you casting this ?

          All widgets have geometry()
          http://doc.qt.io/qt-5/qwidget.html#geometry-prop

          1 Reply Last reply
          0
          • B BrianE

            I am opening a Dialogue to the left of the main window. There is plenty of room and I know how to fix it if there isn't (using a max function) - this is just the bare bones of the problem:

            myDlg->show();
            int xx = x() - myDlg->frameGeometry().width();
            myDlg->move(xx, y());
            

            According to the documentation this ought to cause the right hand edge of the dialogue to be up against the left hand edge of the main window. It isn't! There's a (approx) 15 pixel gap! Is this caused by Win10's 'shadow' nonsense - which I have turned off - or something else? Help would be appreciated.

            raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by
            #5

            @BrianE

            
            myDlg->show();
            int xx = mainWin->geometry().right();
            myDlg->move(xx, y());
            

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            1
            • B Offline
              B Offline
              BrianE
              wrote on last edited by
              #6

              The only thing that has worked so far is this:

                  myDlg->show();
                  int xx = MainWindow::geometry().x() - myDlg->frameGeometry().width();
                  myDlg->move(xx, y());
              

              However, there is still a six or seven pixel gap between RH edge of myDlg and LH edge of MainWindow.

              More:

              int xx = MainWindow::geometry().x() - myDlg->geometry().width();
              

              gives you an big overlap! and

              int xx = MainWindow::frameGeometry().x() - myDlg->geometry().width();
              

              gives me as close to what I want as we're going to get ie one/two pixel overlap which is understandable.

              This does solve the problem, so thanks for the input, but is absolutely not what I was expecting from the documentation. Mind you, how anything works in Win10 is nothing short of miraculous anyway.

              raven-worxR 1 Reply Last reply
              0
              • B BrianE

                The only thing that has worked so far is this:

                    myDlg->show();
                    int xx = MainWindow::geometry().x() - myDlg->frameGeometry().width();
                    myDlg->move(xx, y());
                

                However, there is still a six or seven pixel gap between RH edge of myDlg and LH edge of MainWindow.

                More:

                int xx = MainWindow::geometry().x() - myDlg->geometry().width();
                

                gives you an big overlap! and

                int xx = MainWindow::frameGeometry().x() - myDlg->geometry().width();
                

                gives me as close to what I want as we're going to get ie one/two pixel overlap which is understandable.

                This does solve the problem, so thanks for the input, but is absolutely not what I was expecting from the documentation. Mind you, how anything works in Win10 is nothing short of miraculous anyway.

                raven-worxR Offline
                raven-worxR Offline
                raven-worx
                Moderators
                wrote on last edited by
                #7

                @BrianE
                oh i thought the whole time you want to display it outside next to the mainwindow.
                See this

                --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                If you have a question please use the forum so others can benefit from the solution in the future

                1 Reply Last reply
                0
                • B Offline
                  B Offline
                  BrianE
                  wrote on last edited by
                  #8

                  ????? That's exactly what I wanted to do! The top left corner of myDlg to be myDlg's width to the left of MainWindow's top left. Basically that means Dlg.TL = Main.TL - Dlg.W and my original code used the documented parts of the window as required. It was using the 'correct' parts that gave the gap between Dlg.R and Main.L and I still don't know why!

                  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