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. Can't resize QWindow
Qt 6.11 is out! See what's new in the release blog

Can't resize QWindow

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 3.4k 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.
  • M Offline
    M Offline
    MartinChan 0
    wrote on last edited by
    #1

    I want to create a QWindow which size is 1920*1080 but I can't,the result is here
    alt text

    Here is my test code:

    #include <QGuiApplication>
    #include <QWindow>
    #include <QApplication>
    #include <QDesktopWidget>
    #include <QDebug>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
    
        QWindow win;
        win.resize(1920,1080);
        win.show();
    
        qDebug()<<QString("The width of screen is %1 and height is %2").
                  arg(QApplication::desktop()->width()).
                  arg(QApplication::desktop()->height());
        qDebug()<<QString("The width of QWindow is %1 and height is %2").
                  arg(win.width()).
                  arg(win.height());
        qDebug()<<QString("The tolerance width of QWindow is %1 and height is %2").
                  arg(win.maximumWidth()).
                  arg(win.maximumHeight());
        return a.exec();
    }
    

    Who can tell me why I can't create a 1920*1080 QWindow?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      hi
      Your screen is not big enough.
      So window is re scaled to fit 1366x768
      try
      setFixedSize(1920, 1080);

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MartinChan 0
        wrote on last edited by
        #3

        I use the subclass of QWindow rather than QWidget,so it didn't have a setFixedSize function...So using the subclass of QWidget is the only way to solve this problem?

        mrjjM 1 Reply Last reply
        0
        • M MartinChan 0

          I use the subclass of QWindow rather than QWidget,so it didn't have a setFixedSize function...So using the subclass of QWidget is the only way to solve this problem?

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @MartinChan-0 said in Can't resize QWindow:

          QWindow

          I have not used QWindow as its used for openGL and native windows.
          If you need such features, QWidgets will not work.

          Why do u want the window to be bigger than the MAX screen ?

          M 1 Reply Last reply
          0
          • mrjjM mrjj

            @MartinChan-0 said in Can't resize QWindow:

            QWindow

            I have not used QWindow as its used for openGL and native windows.
            If you need such features, QWidgets will not work.

            Why do u want the window to be bigger than the MAX screen ?

            M Offline
            M Offline
            MartinChan 0
            wrote on last edited by
            #5

            @mrjj
            Firstly,I find a easy way to solve this problem :-) ,you can set a minimum size of a QWindow use

            win.minimumSize(QSize(1920,1080));
            

            to set its size.

            Secondly, I use it because I want to generate a 1920*1080 picture ,and I have to use OpenGL to draw it (to do some job like anti-aliasing)

            Thank you @mrjj anyway~

            mrjjM 1 Reply Last reply
            0
            • M MartinChan 0

              @mrjj
              Firstly,I find a easy way to solve this problem :-) ,you can set a minimum size of a QWindow use

              win.minimumSize(QSize(1920,1080));
              

              to set its size.

              Secondly, I use it because I want to generate a 1920*1080 picture ,and I have to use OpenGL to draw it (to do some job like anti-aliasing)

              Thank you @mrjj anyway~

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @MartinChan-0
              Ok, that way.
              Well then set Minimum should work just fine.

              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