Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. qformlayout cleanup/repaint after takerow()
QtWS25 Last Chance

qformlayout cleanup/repaint after takerow()

Scheduled Pinned Locked Moved Solved General and Desktop
qformlayouttakerowqt 5.14
5 Posts 3 Posters 102 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mdresser
    wrote on 8 Apr 2025, 18:38 last edited by
    #1

    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?

    8abfd3c1-8862-4d75-8120-8851f406bea9-Screenshot from 2025-04-08 14-20-28.png file:///home/mark/Pictures/Screenshot%20from%202025-04-08%2014-20-28.png7983e682-aea1-4dc8-8b61-29178818931f-Screenshot from 2025-04-08 14-21-11.png file:///home/mark/Pictures/Screenshot%20from%202025-04-08%2014-21-11.pngdbba6dc9-2140-46e3-a82e-20104f4cda9f-Screenshot from 2025-04-08 14-21-58.png file:///home/mark/Pictures/Screenshot%20from%202025-04-08%2014-21-58.png

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mdresser
      wrote on 8 Apr 2025, 19:00 last edited by
      #2

      Followup: using removerow() and recreating the widgets when they are needed seems to work. It isn't obvious to me what takerow() would be useful for.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 8 Apr 2025, 19:07 last edited by
        #3

        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.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        J 1 Reply Last reply 8 Apr 2025, 19:37
        0
        • M mdresser has marked this topic as solved on 8 Apr 2025, 19:16
        • S SGaist
          8 Apr 2025, 19:07

          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.

          J Offline
          J Offline
          JonB
          wrote on 8 Apr 2025, 19:37 last edited by JonB 4 Aug 2025, 19:37
          #4

          @SGaist
          I thought removeRow(), in this and other cases, was just more or less delete takeRow() (here a struct, but delete two members), so quite why it is right when takeRow() is not I'm not sure. Maybe it does some extra invalidating.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 8 Apr 2025, 20:06 last edited by
            #5

            Oh ! My bad !
            I meant that takeRow would allow the OP to not have to recreate the row content every time.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0

            5/5

            8 Apr 2025, 20:06

            • Login

            • Login or register to search.
            5 out of 5
            • First post
              5/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved