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. Why a window (subclass of QWidget) moves after being closed and opened

Why a window (subclass of QWidget) moves after being closed and opened

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 644 Views 1 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.
  • A Offline
    A Offline
    a364858
    wrote on last edited by
    #1

    I define a new subclass of QWidget, QMyWindow, as a customized window.

    QMyWindow * pMyWindow = new QMyWindow(nullptr);
    pMyWindow->setAttribute(Qt::WA_QuitOnClose, false);
    pMyWindow->move(0, 0);
    pMyWindow->show();
    //user can do something and then close it
    pMyWindow->show(); //and its position is lower than before
    

    Every time after being closed and opened, its position becomes lower and lower.

    jsulmJ 1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #8

      Maybe it's a problem with that version that has been fixed. Can you try the latest? As I said - seems to be working fine for me with 5.15.2.

      1 Reply Last reply
      0
      • A a364858

        I define a new subclass of QWidget, QMyWindow, as a customized window.

        QMyWindow * pMyWindow = new QMyWindow(nullptr);
        pMyWindow->setAttribute(Qt::WA_QuitOnClose, false);
        pMyWindow->move(0, 0);
        pMyWindow->show();
        //user can do something and then close it
        pMyWindow->show(); //and its position is lower than before
        

        Every time after being closed and opened, its position becomes lower and lower.

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @a364858 said in Why a window (subclass of QWidget) moves after being closed and opened:

        Every time after being closed and opened, its position becomes lower and lower.

        This is done by the window manager I guess. What is your OS/window manager?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • A Offline
          A Offline
          a364858
          wrote on last edited by a364858
          #3

          @jsulm said in Why a window (subclass of QWidget) moves after being closed and opened:

          @a364858 said in Why a window (subclass of QWidget) moves after being closed and opened:

          Every time after being closed and opened, its position becomes lower and lower.

          This is done by the window manager I guess. What is your OS/window manager?

          Windows 10.

          What's more, it won't get lower and lower if move() is not called.

          QMyWindow * pMyWindow = new QMyWindow(nullptr);
          pMyWindow->setAttribute(Qt::WA_QuitOnClose, false);
          pMyWindow->show(); //default position
          //user can do something and then close it
          pMyWindow->show(); //and it won't move
          
          1 Reply Last reply
          0
          • A Offline
            A Offline
            a364858
            wrote on last edited by
            #4

            '窗口下移动画.gif

            1 Reply Last reply
            0
            • Chris KawaC Offline
              Chris KawaC Offline
              Chris Kawa
              Lifetime Qt Champion
              wrote on last edited by
              #5

              Works correctly for me with Qt 5.15.2 and QWidget or QMainWindow. Maybe it's something specific to your QMyWindow class? Do you have something in its show event maybe? Can you try replacing it with a simle QWidget and see if it still happens? Which Qt version are you using?

              A 2 Replies Last reply
              0
              • Chris KawaC Chris Kawa

                Works correctly for me with Qt 5.15.2 and QWidget or QMainWindow. Maybe it's something specific to your QMyWindow class? Do you have something in its show event maybe? Can you try replacing it with a simle QWidget and see if it still happens? Which Qt version are you using?

                A Offline
                A Offline
                a364858
                wrote on last edited by a364858
                #6
                This post is deleted!
                1 Reply Last reply
                0
                • Chris KawaC Chris Kawa

                  Works correctly for me with Qt 5.15.2 and QWidget or QMainWindow. Maybe it's something specific to your QMyWindow class? Do you have something in its show event maybe? Can you try replacing it with a simle QWidget and see if it still happens? Which Qt version are you using?

                  A Offline
                  A Offline
                  a364858
                  wrote on last edited by
                  #7

                  @Chris-Kawa

                  It's just a simple subclass of QWidget.

                  I'm using Qt 5.13.2.

                  edb3a033ceb4.gif

                  1 Reply Last reply
                  0
                  • Chris KawaC Offline
                    Chris KawaC Offline
                    Chris Kawa
                    Lifetime Qt Champion
                    wrote on last edited by
                    #8

                    Maybe it's a problem with that version that has been fixed. Can you try the latest? As I said - seems to be working fine for me with 5.15.2.

                    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