setGeometry Unable to set geometry
-
Message:
QWindowsWindow::setGeometry: Unable to set geometry 1246x801+-2928+446 on QWidgetWindow/'MainWindowsWindow'. Resulting geometry: 1252x818+-2928+446 (frame: 8, 31, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 1246x801, maximum size: 16777215x16777215).I've single stepped the application to the point where:
mpMainWnd->show();Calling show results in the message posted above being displayed...why? I've reported the geometry which is:
QRect(0,0 732x480)The window appears centred in the display, why am I seeing this message and how can I get rid of it?
[Edit], Qt 5.9.2 on Windows 10 with MSVC 2015, primary display size 5120 x 1140
-
Message:
QWindowsWindow::setGeometry: Unable to set geometry 1246x801+-2928+446 on QWidgetWindow/'MainWindowsWindow'. Resulting geometry: 1252x818+-2928+446 (frame: 8, 31, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 1246x801, maximum size: 16777215x16777215).I've single stepped the application to the point where:
mpMainWnd->show();Calling show results in the message posted above being displayed...why? I've reported the geometry which is:
QRect(0,0 732x480)The window appears centred in the display, why am I seeing this message and how can I get rid of it?
[Edit], Qt 5.9.2 on Windows 10 with MSVC 2015, primary display size 5120 x 1140
@SPlatten said in setGeometry Unable to set geometry:
I've reported the geometry which is
What do you mean by "reported"?
Do you mean you print it out? If so where? -
@SPlatten said in setGeometry Unable to set geometry:
I've reported the geometry which is
What do you mean by "reported"?
Do you mean you print it out? If so where? -
Hi
It might be the old bug
https://bugreports.qt.io/browse/QTBUG-73258I have seen it on Linux with 5.9 even its listed as 5.12
you can try set minimumsize on it to
1246x801 if you haven't done already.- QRect(0,0 732x480)
when do you print this out ? The window must be visible at that time
or the numbers might mean nothing.
- QRect(0,0 732x480)
-
Hi
It might be the old bug
https://bugreports.qt.io/browse/QTBUG-73258I have seen it on Linux with 5.9 even its listed as 5.12
you can try set minimumsize on it to
1246x801 if you haven't done already.- QRect(0,0 732x480)
when do you print this out ? The window must be visible at that time
or the numbers might mean nothing.
@mrjj , thank you, I just tried that, still the same:
QWindowsWindow::setGeometry: Unable to set geometry 732x480+-2928+446 on QWidgetWindow/'MainWindowWindow'. Resulting geometry: 738x497+-2928+446 (frame: 8, 31, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 732x480, maximum size: 16777215x16777215). - QRect(0,0 732x480)
-
@mrjj , thank you, I just tried that, still the same:
QWindowsWindow::setGeometry: Unable to set geometry 732x480+-2928+446 on QWidgetWindow/'MainWindowWindow'. Resulting geometry: 738x497+-2928+446 (frame: 8, 31, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 732x480, maximum size: 16777215x16777215).Hello!
I have the same issue previously. I fixed it by increasing the size of window/dialog. Try to change the width/height of your window.
For example, set740x480or740x500. Please let me know if this works for you. Happy coding! -
Hello!
I have the same issue previously. I fixed it by increasing the size of window/dialog. Try to change the width/height of your window.
For example, set740x480or740x500. Please let me know if this works for you. Happy coding!@Cobra91151 , size isn't a problem :). really it isn't, it does look like a bug as I'm not sure why the message is reporting -2928 for the width?
-
@Cobra91151 , size isn't a problem :). really it isn't, it does look like a bug as I'm not sure why the message is reporting -2928 for the width?
I do not think -2928 is the width. It is the
rect.x()position. In your case the width is732, height -480, x -2928and y -446.You can check out the source:
void QWindowsWindow::setGeometry(const QRect &rectIn) { QRect rect = rectIn; // This means it is a call from QWindow::setFramePosition() and // the coordinates include the frame (size is still the contents rectangle). if (QWindowsGeometryHint::positionIncludesFrame(window())) { const QMargins margins = frameMargins(); rect.moveTopLeft(rect.topLeft() + QPoint(margins.left(), margins.top())); } if (m_windowState == Qt::WindowMinimized) m_data.geometry = rect; // Otherwise set by handleGeometryChange() triggered by event. if (m_data.hwnd) { // A ResizeEvent with resulting geometry will be sent. If we cannot // achieve that size (for example, window title minimal constraint), // notify and warn. setGeometry_sys(rect); if (m_data.geometry != rect && (isVisible() || QLibraryInfo::isDebugBuild())) { qWarning("%s: Unable to set geometry %dx%d+%d+%d on %s/'%s'." " Resulting geometry: %dx%d+%d+%d " "(frame: %d, %d, %d, %d, custom margin: %d, %d, %d, %d" ", minimum size: %dx%d, maximum size: %dx%d).", __FUNCTION__, rect.width(), rect.height(), rect.x(), rect.y(), window()->metaObject()->className(), qPrintable(window()->objectName()), m_data.geometry.width(), m_data.geometry.height(), m_data.geometry.x(), m_data.geometry.y(), m_data.frame.left(), m_data.frame.top(), m_data.frame.right(), m_data.frame.bottom(), m_data.customMargins.left(), m_data.customMargins.top(), m_data.customMargins.right(), m_data.customMargins.bottom(), window()->minimumWidth(), window()->minimumHeight(), window()->maximumWidth(), window()->maximumHeight()); } } else { QPlatformWindow::setGeometry(rect); } }So, I think the widget geometry is smaller than the layout contents, that is why it reports such issue. You can try to
adjustSizemethod (https://doc.qt.io/archives/qt-5.9/qwidget.html#adjustSize) or you can set it manually.Code:
mpMainWnd->adjustSize(); mpMainWnd->show();For example in your case it reports as
738x497to fix this issue or make it bigger as I suggested in my previous post. -
@Cobra91151 , I've now changed the minimum width and height to 1200x800, still getting:
QWindowsWindow::setGeometry: Unable to set geometry 1200x800+-3162+286 on QWidgetWindow/'MainWindowWindow'. Resulting geometry: 1206x817+-3162+286 (frame: 8, 31, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 1200x800, maximum size: 16777215x16777215).I took a screen shot of the window and pasted into Paint, the size of the final window is 1208x849.
-
@Cobra91151 , I've now changed the minimum width and height to 1200x800, still getting:
QWindowsWindow::setGeometry: Unable to set geometry 1200x800+-3162+286 on QWidgetWindow/'MainWindowWindow'. Resulting geometry: 1206x817+-3162+286 (frame: 8, 31, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 1200x800, maximum size: 16777215x16777215).I took a screen shot of the window and pasted into Paint, the size of the final window is 1208x849.
Ok. It would be better to create some minimal test project to reproduce this issue, so I can find a solution.
The reason could be a missingparent, widgets size/layouts issue etc. -
@Cobra91151 , thank you, but sorry, that would take more time than I have right now.
-
Ok. It would be better to create some minimal test project to reproduce this issue, so I can find a solution.
The reason could be a missingparent, widgets size/layouts issue etc.@Cobra91151 If the MainWindow is the at the top level of the application, there isn't a parent is there?
-
@Cobra91151 If the MainWindow is the at the top level of the application, there isn't a parent is there?
@SPlatten said in setGeometry Unable to set geometry:
@Cobra91151 If the MainWindow is the at the top level of the application, there isn't a parent is there?
If you mean something like this:
Code:
int main(int argc, char *argv[]) { QApplication a(argc, argv); Dialog w; w.show(); return a.exec(); }Then no parent is needed. But, if you have some object class in which you check what dialog to display as the top level, then I would suggest
setParentto the app object:Code:
int main(int argc, char *argv[]) { QApplication a(argc, argv); MyStartup obj; obj.setParent(&a); return a.exec(); }But I do not think it will fix your issue. Have you tried for example:
setFixedSizemethod to check if this issue still exists? Also, you can setsetWindowFlagsmethod:Qt::MSWindowsFixedSizeDialogHintto make window not resizable onWindowsjust for a test.Additionally, you can try to find what causes it using the code below in your
mainmethod (main.cpp):#ifdef QT_DEBUG qputenv("QT_FATAL_WARNINGS", "1"); qputenv("QT_MESSAGE_PATTERN", "Type: %{type}\nProduct Name: %{appname}\nFile: %{file}\nLine: %{line}\nMethod: %{function}\nThreadID: %{threadid}\nThreadPtr: %{qthreadptr}\nMessage: %{message}"); #endifIt will work only in
Debugmode and should display more details about your issue. Without any code it is hard to find the root of your issue.