qformlayout cleanup/repaint after takerow()
-
Using Qt 5.14.0, I have created a formlayout to edit a list of parameters. Depending on the state of a checkbox, several rows are inserted or taken out. All works as I want, except that the text for the taken rows is not cleared. This results in the images below:
The code in question is this:
void EC_tab::insertPID(int state) { if (state != 0) { formLayout->insertRow(12, new QLabel(tr("Proportional Constant:")),PID_Kp); formLayout->insertRow(13, new QLabel(tr("Integral Constant")),PID_Ki); formLayout->insertRow(14, new QLabel(tr("Derivative Constant:")),PID_Kd); formLayout->insertRow(15, new QLabel(tr("Anti-Windup Constant:")),PID_Ks); } else { formLayout->takeRow(PID_Kp); formLayout->takeRow(PID_Ki); formLayout->takeRow(PID_Kd); formLayout->takeRow(PID_Ks); } setLayout(formLayout); //I've tried adding this but it doesn't help }
Is there something else I need to do to repaint the form after taking rows?
file:///home/mark/Pictures/Screenshot%20from%202025-04-08%2014-20-28.png
file:///home/mark/Pictures/Screenshot%20from%202025-04-08%2014-21-11.png
file:///home/mark/Pictures/Screenshot%20from%202025-04-08%2014-21-58.png
-
Hi,
AFAIR, there have been some patches related to takeRow (but it's been some time).
It's technically exactly the method you want to use however 5.14 is pretty outdated. If possible you should try the latest 5.15 if not Qt 6. -
-
Hi,
AFAIR, there have been some patches related to takeRow (but it's been some time).
It's technically exactly the method you want to use however 5.14 is pretty outdated. If possible you should try the latest 5.15 if not Qt 6. -
Oh ! My bad !
I meant that takeRow would allow the OP to not have to recreate the row content every time.