Problem with widget
-
I'm having a problem with a widget so in an effort to see what is going on I want to add an additional rectangle to the widget so I can render debug information to this new rectangle.
In the paintEvent I get the geometry:
QRect rctGeom(rect()); #if defined(TRUTH_DEV) if ( mblnVisibleCopy == true && mrctDev.isEmpty == true ) { //Adjust widget geometry allowing for the development area int intWidth(rctGeom.width()); rctGeom.adjust(0, 0,intWidthh, 0); qDebug() << "BEFORE: " << rctGeom; setGeometry(rctGeom); qDebug() << "AFTER: " << geometry(); mrctDev = rctGeom; mrctDev.adjust(intWidth, + 40, intWidth, -40); qDebug() << "rctGeom: " << rctGeom << ", mrctDev: " << mrctDev; } #endifThe output from above is:
BEFORE: QRect(0,0 416x644) AFTER: QRect(0,0 208x644) rctGeom: QRect(0,0 416x644), mrctDev: QRect(208,40 416x564)I'm not sure why the geometry in the AFTER message has a narrow width after calling setGeometry.
[Edit], I just tried:QRect rctGeom(rect()); #if defined(TRUTH_DEV) if ( mblnVisibleCopy == true && mrctDev.isEmpty == true ) { //Adjust widget geometry allowing for the development area int intWidth(rctGeom.width()); qDebug() << "BEFORE: " << rctGeom; resize(intWidth*2, rctGeom.height()); qDebug() << "AFTER: " << geometry(); mrctDev = rctGeom; mrctDev.adjust(intWidth, + 40, intWidth, -40); qDebug() << "rctGeom: " << rctGeom << ", mrctDev: " << mrctDev; } #endifNow the output is:
BEFORE: QRect(0,0 208x644) AFTER: QRect(897,32 208x644) rctGeom: QRect(0,0 208x644), mrctDev: QRect(208,40 208x564)I'm very confused.
-
I'm having a problem with a widget so in an effort to see what is going on I want to add an additional rectangle to the widget so I can render debug information to this new rectangle.
In the paintEvent I get the geometry:
QRect rctGeom(rect()); #if defined(TRUTH_DEV) if ( mblnVisibleCopy == true && mrctDev.isEmpty == true ) { //Adjust widget geometry allowing for the development area int intWidth(rctGeom.width()); rctGeom.adjust(0, 0,intWidthh, 0); qDebug() << "BEFORE: " << rctGeom; setGeometry(rctGeom); qDebug() << "AFTER: " << geometry(); mrctDev = rctGeom; mrctDev.adjust(intWidth, + 40, intWidth, -40); qDebug() << "rctGeom: " << rctGeom << ", mrctDev: " << mrctDev; } #endifThe output from above is:
BEFORE: QRect(0,0 416x644) AFTER: QRect(0,0 208x644) rctGeom: QRect(0,0 416x644), mrctDev: QRect(208,40 416x564)I'm not sure why the geometry in the AFTER message has a narrow width after calling setGeometry.
[Edit], I just tried:QRect rctGeom(rect()); #if defined(TRUTH_DEV) if ( mblnVisibleCopy == true && mrctDev.isEmpty == true ) { //Adjust widget geometry allowing for the development area int intWidth(rctGeom.width()); qDebug() << "BEFORE: " << rctGeom; resize(intWidth*2, rctGeom.height()); qDebug() << "AFTER: " << geometry(); mrctDev = rctGeom; mrctDev.adjust(intWidth, + 40, intWidth, -40); qDebug() << "rctGeom: " << rctGeom << ", mrctDev: " << mrctDev; } #endifNow the output is:
BEFORE: QRect(0,0 208x644) AFTER: QRect(897,32 208x644) rctGeom: QRect(0,0 208x644), mrctDev: QRect(208,40 208x564)I'm very confused.
@SPlatten
possibly:The size component is adjusted if it lies outside the range defined by minimumSize() and maximumSize().
-
@SPlatten
possibly:The size component is adjusted if it lies outside the range defined by minimumSize() and maximumSize().
@J-Hilk , thank you, modified to:
QRect rctGeom(rect()); #if defined(TRUTH_DEV) if ( mblnVisibleCopy == true && mrctDev.isEmpty == true ) { //Save current size Size szCurrent(size()), szNew; //Adjust maxmum size to prevent geometry being rejected szNew.setWidth(szCurrent.width() * 2); szNew.setHeight(szCurrent.height()); //Adjust widget geometry allowing for the development area qDebug() << "BEFORE: " << rctGeom; resize(szNew); rctGeom = geometry(); qDebug() << "AFTER: " << rctGeom; mrctDev = rctGeom; mrctDev.adjust(szCurrent.width(), + 40, szCurrent.width(), -40); qDebug() << "rctGeom: " << rctGeom << ", mrctDev: " << mrctDev; } #endifResults:
BEFORE: QRect(0,0 208x644) AFTER: QRect(897,32 416x644) rctGeom: QRect(897,32 416x644), mrctDev: QRect(1105,72 416x564)Thank you!