When you setText of the button, the Geometry changes.
-
void wFunctionMenu::BtnResize() { QRect rect( this->ui.verticalLayout->contentsMargins().left(), this->ui.verticalLayout->contentsMargins().top(), this->size().width() - (this->ui.verticalLayout->contentsMargins().left() + this->ui.verticalLayout->contentsMargins().right()), (this->size().height() - (this->ui.verticalLayout->contentsMargins().bottom() + this->ui.verticalLayout->spacing() * m_nBtnCnt - 1)) / m_nBtnCnt ); this->ui.btn_CnP ->setGeometry(rect); this->ui.btn_NewF ->setGeometry(rect.x(), this->ui.btn_CnP->geometry().y() + rect.height() + this->ui.verticalLayout->spacing(), rect.width(), rect.height()); this->ui.btn_Rename ->setGeometry(rect.x(), this->ui.btn_NewF->geometry().y() + rect.height() + this->ui.verticalLayout->spacing(), rect.width(), rect.height()); this->ui.btn_Delete ->setGeometry(rect.x(), this->ui.btn_Rename->geometry().y() + rect.height() + this->ui.verticalLayout->spacing(), rect.width(), rect.height()); }
In class Initialize, the position of the button is specified through the setGeometry function.
And change the text of the button according to the external flag.
When you change the button text, the geometry changes to the layout set in Qt Designer. The button size is also changed to the original size.Why does this happen? Is it a bug?
-
@IknowQT said in When you setText of the button, the Geometry changes.:
the geometry changes to the layout set in Qt Designer
If you set the geometry manually why did you put the button into a layout?
-
@IknowQT said in When you setText of the button, the Geometry changes.:
I don't think that would be a problem.
Based on what? You think it is a bug in Qt instead? How do putting a widget on a layout, which controls its position, and setting its geometry, which sets its position, interact with each other?
-
@IknowQT said in When you setText of the button, the Geometry changes.:
This is to make it easier to manage without creating an object
It still does not make sence to put widgets into a layout if you want to set their geometry manually.
Why don't you use layouts? What is the benefit doing positioning/sizing manually? -
Are you saying you have to manually create the object to use the geometry?
I'll test it with the object creation method and tell you the resultThe question seems to have been understood if the set geometry did not work even during Initialize.
However, the question remains as to whether the geometry works when initialized and returns to the original state when setText is executed.One of the things I tested was calling the geometry defined function again after calling setText. Nevertheless, it was not in the desired position.