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. How To Get The Full Width Of A Maxamized Window
Qt 6.11 is out! See what's new in the release blog

How To Get The Full Width Of A Maxamized Window

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.5k 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.
  • E Offline
    E Offline
    EverydayDiesel
    wrote on last edited by
    #1

    Hello, I have the following code that should return something similar to 1920 but instead it gives me 1117.

    Can anyone please tell me why?

    @
    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);

    QMainWindow::showFullScreen();
    
    int iWidth1 = this->geometry().width(); 
    int iWidth2 = this->size().width();
    

    @

    Both Width1 and Width2 return the same value

    Thanks in advance

    Edit:

    After looking I see that the default window size is 1117 which means that even though I am calling fullscreen and then getting the window width, it is not getting the new width since 1117 is the old width.
    How can I force it to get the new/current width?

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      AFAIK, you won't get it in the constructor. Either call a function from other than constructor and fetch the size. Or other way would be to call this from constructor:
      @
      QTimer::singleShot(1000,this,SLOT(getSizeMainWindow()));
      @

      where getSizeMainWindow() contains code to get the size.

      157

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        The single shot can be 0, IIRC it should get call once the constructor is ended

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        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