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. MoveLeft() not working
QtWS25 Last Chance

MoveLeft() not working

Scheduled Pinned Locked Moved General and Desktop
14 Posts 5 Posters 3.8k Views
  • 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.
  • N Offline
    N Offline
    Neutron Stein
    wrote on last edited by
    #2

    I think you can't change the position of the menu bar with code.

    Never Seen !

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

      Thanks :-)

      It is not a menu bar, it is a QListView to display a list of menu items.

      Cannot get the code to work for any widget.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #4

        QWidget->rect() returns a QRect, not a QRect& (a reference to a rect). That is, it is a copy of the rect of your widget, but that rect is not connected to the rect of the widget itself.

        What you need to do, is get the widget geometry, adjust it to your liking, and then set the result on the widget again with the setter.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          Dolphin
          wrote on last edited by
          #5

          Ha ha! A reference, now that I understand, ta.

          1 Reply Last reply
          0
          • D Offline
            D Offline
            Dolphin
            wrote on last edited by
            #6

            So why does this not work - at the end of my method I check the QlistView geometry and it is correct (with the new values AND the listView is updated on screen) but looping through the next time it has the old values

            @ QRect screenRect = geometry();
            QRect menuRect = ui.menu->geometry();

            menuRect.getCoords(&x1, &y1, &x2, &y2);
            screenRect.getCoords(&screen_x1, &screen_y1, &screen_x2, &screen_y2);
            int width(menuRect.width() * 1.5);
            x1 = (screen_x2 - width)/2;
            x2 = x1 + width;
            menuRect.setCoords(x1, y1, x2, y2);
            ui.menu->setGeometry(menuRect);@

            1 Reply Last reply
            0
            • Q Offline
              Q Offline
              qxoz
              wrote on last edited by
              #7

              If you want move the widget why not use move(x,y)
              @ui.menu->move(x,y)@

              1 Reply Last reply
              0
              • D Offline
                D Offline
                Dolphin
                wrote on last edited by
                #8

                You would think, right?? I tried that first but it is not getting applied when the window loads so the first positioning of the listView is wrong. Having worked with all the different repositioning options I can see it is something to do with loading the main window because they all give the same result.

                My software uses Ctrl+F12 to increase the font size of the listView and therefore reposition the listView (since everything is bigger) and that positions everything fine, so the code is working - when I start the app it is running through the Ctrl+F12 code but not putting the listView in the right place (positions it as it is in the ui).

                I am doing the reposition code after window.showFullScreen() so the mainwindow.geometry() is accurate for calculations but the listVeiw STILL positions as per the ui even though my numbers are accurate and the reposition code is the last thing done, no other code after it. Frustrating :-S

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  tobias.hunger
                  wrote on last edited by
                  #9

                  Why can't you use layouts? They handle size changes of widgets fine without any magic.

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    Dolphin
                    wrote on last edited by
                    #10

                    Tried that but things start over lapping themselves and I lack the experience to get that working. I basically need a specialised 'zoom' (product is for visually impaired).

                    If you can tell me how to I can do it I will try anything :-)

                    1. Top of screen - scrolling text area, 3 tool buttons with icons all in a line.
                    2. Underneath - centred label.
                    3. Main part of the window - listView

                    Users need to be able to increase the size of 3 with 1 & 2 staying the same size and increase 1 & 2 with 3 staying the same size.

                    Need to cope with 200pt font.

                    1 Reply Last reply
                    0
                    • T Offline
                      T Offline
                      tobias.hunger
                      wrote on last edited by
                      #11

                      How can you have 3 stay the same size while 1 & 2 change theirs when e.g. full screen? Apart from that requirement layouts should work very well. I don't see how things can start to overlap once they are in a layout.

                      1 Reply Last reply
                      0
                      • D Offline
                        D Offline
                        Dolphin
                        wrote on last edited by
                        #12

                        That is what I have to sort out - works fine in the old VB code.

                        OK, so if I start a new project with a scroll area and 3 buttons on the main window I notice that if I click "horizontal layout" and increase the size of the items things are ok. If I select the items and click "horizontal layout" things do not work correctly (that is what I have been doing with the stuff at the top because I do not want the listView in the layout). So this is where the problem is coming in - seems as if layouts only work correctly if the whole window is in one layout.......... I need the top and bottom to behave independently. So I basically need to create a widget for the top and one for the bottom so they can each have their own layouts??

                        Sorry if I am being thick but I have never done Gui (or used Qt) before, always been the back end pointers and long numbers bod.

                        1 Reply Last reply
                        0
                        • T Offline
                          T Offline
                          tobias.hunger
                          wrote on last edited by
                          #13

                          Layouts can be nested. You can also put QWidgets with layouts into layouts.

                          Read up on layouts and play around a bit with qt designer. That is a really nice tool to quickly try out UIs.

                          1 Reply Last reply
                          0
                          • D Offline
                            D Offline
                            Dolphin
                            wrote on last edited by
                            #14

                            Yep, been nesting them but not been able to get it working :-(

                            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