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. Qt 6.5.3 : Can't change QWidget position
QtWS25 Last Chance

Qt 6.5.3 : Can't change QWidget position

Scheduled Pinned Locked Moved Solved General and Desktop
qwidgetpositiongeometry
6 Posts 3 Posters 745 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.
  • P Offline
    P Offline
    paulo95
    wrote on 28 Sept 2023, 21:32 last edited by paulo95
    #1

    Hello everyone.

    I have problem with my QWidget window which I can't update position.
    I don't use the Ui tool.

    (aw_ is a QWidget)

    I've tried:

    QRect           screenGeometry;
    int             x;
    int             y;
    
    screenGeometry = QApplication::primaryScreen()->geometry();
    x = (screenGeometry.width() - aw_.width()) / 2;
    y = (screenGeometry.height() - aw_.height()) / 2;
    aw_.move(x, y);
    aw_.show();
    

    but the window doesn't move.

    I also tried :

    QRect           screenGeometry;
    int             x;
    int             y;
    
    screenGeometry = QApplication::primaryScreen()->geometry();
    x = screenGeometry.center().x();
    y = screenGeometry.center().y();
    aw_.setUpdatesEnabled(true);
    aw_.setGeometry(x, y, 400, 300);
    QApplication::processEvents();
    aw_.show();
    

    There the size of the window changed but remains stuck a random point on the screen.

    I also tried to create a new project with a Ui and I saw in the Design panel that the values of X and Y of the geometry property can't be changed (they're disabled) but not width and height.

    Does anyone has an idea?

    Thanks in advance.

    J 1 Reply Last reply 28 Sept 2023, 21:46
    0
    • P paulo95
      28 Sept 2023, 21:32

      Hello everyone.

      I have problem with my QWidget window which I can't update position.
      I don't use the Ui tool.

      (aw_ is a QWidget)

      I've tried:

      QRect           screenGeometry;
      int             x;
      int             y;
      
      screenGeometry = QApplication::primaryScreen()->geometry();
      x = (screenGeometry.width() - aw_.width()) / 2;
      y = (screenGeometry.height() - aw_.height()) / 2;
      aw_.move(x, y);
      aw_.show();
      

      but the window doesn't move.

      I also tried :

      QRect           screenGeometry;
      int             x;
      int             y;
      
      screenGeometry = QApplication::primaryScreen()->geometry();
      x = screenGeometry.center().x();
      y = screenGeometry.center().y();
      aw_.setUpdatesEnabled(true);
      aw_.setGeometry(x, y, 400, 300);
      QApplication::processEvents();
      aw_.show();
      

      There the size of the window changed but remains stuck a random point on the screen.

      I also tried to create a new project with a Ui and I saw in the Design panel that the values of X and Y of the geometry property can't be changed (they're disabled) but not width and height.

      Does anyone has an idea?

      Thanks in advance.

      J Offline
      J Offline
      JoeCFD
      wrote on 28 Sept 2023, 21:46 last edited by
      #2

      @paulo95 OS?

      1 Reply Last reply
      0
      • P Offline
        P Offline
        paulo95
        wrote on 28 Sept 2023, 21:54 last edited by
        #3

        Debian 12

        J 1 Reply Last reply 28 Sept 2023, 22:20
        0
        • P paulo95
          28 Sept 2023, 21:54

          Debian 12

          J Offline
          J Offline
          JonB
          wrote on 28 Sept 2023, 22:20 last edited by JonB
          #4

          @paulo95
          If/assuming you are running under Wayland you will find you can do little to position windows. Several threads in this forum to that effect. Use Xorg if you must do so.

          P 1 Reply Last reply 28 Sept 2023, 23:03
          1
          • J JonB
            28 Sept 2023, 22:20

            @paulo95
            If/assuming you are running under Wayland you will find you can do little to position windows. Several threads in this forum to that effect. Use Xorg if you must do so.

            P Offline
            P Offline
            paulo95
            wrote on 28 Sept 2023, 23:03 last edited by
            #5

            @JonB

            Thanks for you answer.
            Yes I'm under Wayland.
            Already had problem with it : had marshal_proxy_plugin error when running empty QtWidget Application under Debian 11. Had to migrate to Debian 12 to have recent version of libwayland.

            Currently switching to Xorg at login screen makes me gray screen.
            I'm keeping you posted when solved this and tried.

            P 1 Reply Last reply 29 Sept 2023, 00:46
            0
            • P paulo95
              28 Sept 2023, 23:03

              @JonB

              Thanks for you answer.
              Yes I'm under Wayland.
              Already had problem with it : had marshal_proxy_plugin error when running empty QtWidget Application under Debian 11. Had to migrate to Debian 12 to have recent version of libwayland.

              Currently switching to Xorg at login screen makes me gray screen.
              I'm keeping you posted when solved this and tried.

              P Offline
              P Offline
              paulo95
              wrote on 29 Sept 2023, 00:46 last edited by
              #6

              @JonB
              @JoeCFD

              OK found that Wayland just doesn't allow to windows to move themselves.

              Not a necessary feature for me and can't solve the black screen problem when logging with Xorg.
              Will just ask gnome to center new windows with tweaks.

              Closing the topic.

              Thanks to both you.

              1 Reply Last reply
              0
              • P paulo95 has marked this topic as solved on 29 Sept 2023, 00:46

              1/6

              28 Sept 2023, 21:32

              • Login

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