get mainwindow size?
Solved
General and Desktop
-
-
@JoeCFD
In a word, "No". If you need to access the main window (or any other window) from deep down in code you do need a helper function like you have found. You can make yours (maybe) a bit faster: I usedQGuiApplication::topLevelWindows()
for top-level only (no parent) as that will be what main window is, I don't know if Qt can produce that faster thanallWindows()
.I found it fine, speed-wise. Of course if you do it a lot you could always cache the result fur re-use.
I prefer this to saving some "globally accessible variable" which you set with the main window when you first create it. But of course that would be fast.
-
-
-
Hi,
Out of curiosity, why do you need that information deep in your code ?