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. Get size of mainwindow and set width and height of a widget
Qt 6.11 is out! See what's new in the release blog

Get size of mainwindow and set width and height of a widget

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 592 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.
  • K Offline
    K Offline
    Kris Revi
    wrote on last edited by
    #1

    so what i have made is this

    void MainWindow::on_pushButtonMaximize_clicked()
    {
        QSize size = this->size();
    
        if(isMaximized() == false)
        {
            showMaximized();
            ui->quickWidget->setGeometry(0, 0, size.width(), size.height());
        }
        else
        {
            showNormal();
            ui->quickWidget->setGeometry(0, 0, 1280, 720);
        }
    
        qDebug() << "MainWindow Width : " << this->size().width() << "MainWindow Height : " << this->size().height();
    }
    

    what im trying todo is on showMaximized i want to set quickWidget to the size of mainwindow and then hard set it back when showNormal is set

    but when i press the Maximize button (to maximize the window) i only get the "current" so 1280x720
    and when i press the Maximize button again THEN it gets the 1920x1080

    im having a huge brainfart over this.... how to fix this?

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Use layouts instead.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      K 1 Reply Last reply
      2
      • Christian EhrlicherC Christian Ehrlicher

        Use layouts instead.

        K Offline
        K Offline
        Kris Revi
        wrote on last edited by Kris Revi
        #3

        @Christian-Ehrlicher i cant that is the problem! AFAIK i cant have a layout the way i have setup this

        0ac16e94-cf46-48a7-86b9-99985eee26e4-image.png

        the quickWidget is QML file with an animation background and then i have the frame (QFrame) onTOP of that! when using layout this is not possible AFAIK!

        jsulmJ 1 Reply Last reply
        0
        • K Kris Revi

          @Christian-Ehrlicher i cant that is the problem! AFAIK i cant have a layout the way i have setup this

          0ac16e94-cf46-48a7-86b9-99985eee26e4-image.png

          the quickWidget is QML file with an animation background and then i have the frame (QFrame) onTOP of that! when using layout this is not possible AFAIK!

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

          @Kris-Revi According to the picture quickWidget is child of frame_2 (means quickWidget is INSIDE frame_2). So, why can't you have a layout?

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

          K 1 Reply Last reply
          0
          • jsulmJ jsulm

            @Kris-Revi According to the picture quickWidget is child of frame_2 (means quickWidget is INSIDE frame_2). So, why can't you have a layout?

            K Offline
            K Offline
            Kris Revi
            wrote on last edited by
            #5

            @jsulm if i set a layout on frame_2 , frame wont stack onTOP of quickWidget

            Thank YouT 1 Reply Last reply
            0
            • K Kris Revi

              @jsulm if i set a layout on frame_2 , frame wont stack onTOP of quickWidget

              Thank YouT Offline
              Thank YouT Offline
              Thank You
              wrote on last edited by
              #6

              @Kris-Revi

              ```
              

              QRect mainGm = ui->centralwidget->geometry();
              ui->yourWidget->setGeometry(mainGm);

              Get geometry and set the geometry of children widget

              Let's make QT free or It will go forever

              TRUE AND FALSE <3

              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