Geometry looks invalid but calling isValid returns true.
-
In my parent window I pass this to the dialog constructor, I've checked the geometry of the parent window and for some reason it contains:
x1 -2900 y1 490 x2 -2226 y2 961I've single stepped into the constructor where I have:
QRect rctGeom(pParent->geometry()); rctGeom.setHeight(DataSets::mscuint16Height); rctGeom.setWidth(DataSets::mscuint16Width); if ( rctGeom.isValid() == true ) { setGeometry(rctGeom); }After setting the height and width the geometry contains:
x1 -2900 y1 410 x2 -2445 y2 949mscuint16Height contains 540, mscuint16Width contains 456. I've single stepped onto the isValid call and it does return true which I find very odd given that both x1 and x2 are both negative. After calling setGeometry I see in the console:
QWindowsWindow::setGeometry: Unable to set geometry 480x540+-2900+410 on QWidgetWindow/'DataSetsClassWindow'. Resulting geometry: 486x540+-2900+410 (frame: 8, 31, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 480x482, maximum size: 16777215x16777215).Reading the documentation:
https://doc.qt.io/qt-5/qrect.html#isValid
It is certainly doing what it says on the documentation, but personally I think the logic needs and should be changed to validate if the geometry results in a non-visible rectangle as this does.This is the logic it currently uses:
A valid rectangle has a left() <= right() and top() <= bottom().I think it should be: A valid rectangle should be:
right() - left() > 0 and top() - bottom() > 0 and left() <= right() and top() <= bottom() -
I don't see why a rectangle must have postive width or height...
-
Hi
single stepped into the constructor
You cannot trust size values when in a constructor as Qt will queue certain
operation until actual shown.Try to do the same in showEvent and see.