How to update label position which is added on mainwindhow.ui using QT programatically?
-
Hi Team, I have added one label called 'lable_new' on the "exampletwo.ui". This label is coming as expected when I run the QT application. But when I want to change the label position using programmatically using below the line in "exampletwo.php".
ui->lable_new->setGeometry(300, 500, 250, 250);
This newly, the updated position is coming and disappearing, and the label position is coming in old position instead of taking the above-updated position. Am I doing something wrong? Thanks in advance.
-
@NageswaRao said in How to update label position which is added on mainwindhow.ui using QT programatically?:
using below the line in "exampletwo.php"
What is this file? Looks like PHP.
Can you show actual code?
Is this label in a layout? -
@jsulm said in How to update label position which is added on mainwindhow.ui using QT programatically?:
Is this label in a layout?
Yes. This label in a layout only
-
@NageswaRao said in How to update label position which is added on mainwindhow.ui using QT programatically?:
This label in a layout only
In this case the layout handles the position and size of the label. Why do you want to use setGeometry on a widget which is in a layout?
-
@NageswaRao Then remove the label from layout
-
@jsulm you mean I need to add a label from the CPP code right? Like below link.
https://stackoverflow.com/questions/39348635/qt-add-label-to-certain-position
-
@NageswaRao said in How to update label position which is added on mainwindhow.ui using QT programatically?:
you mean I need to add a label from the CPP code right?
No, you just should not add it to any layouts