How To Get The Full Width Of A Maxamized Window
-
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? -
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.
-
Hi,
The single shot can be 0, IIRC it should get call once the constructor is ended