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. is it possible to change the default behavior of a checkable QGroupBox?

is it possible to change the default behavior of a checkable QGroupBox?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qgroupbox
3 Posts 3 Posters 575 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.
  • S Offline
    S Offline
    Savio Brilhante
    wrote on 10 Mar 2020, 06:21 last edited by
    #1

    The question is pretty straight forward: is it possible to change the default behavior of a checkable QGroupBox object? I designed a user interface with many QLineEdit objects inside a checkable QGroupBox, the desired behavior is: when QGroupBox is not checked all of its children are enable and when it is checked all of its children are disable.

    As you can see at the oficial QGroupBox documentation, it says:

    If the check box is checked, the group box's children are enabled; otherwise, the children are disabled and are inaccessible to the user.

    J 1 Reply Last reply 10 Mar 2020, 07:58
    0
    • S Savio Brilhante
      10 Mar 2020, 06:21

      The question is pretty straight forward: is it possible to change the default behavior of a checkable QGroupBox object? I designed a user interface with many QLineEdit objects inside a checkable QGroupBox, the desired behavior is: when QGroupBox is not checked all of its children are enable and when it is checked all of its children are disable.

      As you can see at the oficial QGroupBox documentation, it says:

      If the check box is checked, the group box's children are enabled; otherwise, the children are disabled and are inaccessible to the user.

      J Offline
      J Offline
      JonB
      wrote on 10 Mar 2020, 07:58 last edited by JonB 3 Oct 2020, 07:58
      #2

      @Savio-Brilhante
      I don't see that you can alter the default behaviour. However, you may be able to subclass and provide your own reversed behaviour for child enablement.

      1 Reply Last reply
      2
      • M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 10 Mar 2020, 20:17 last edited by mrjj 3 Oct 2020, 20:19
        #3

        Hi
        You can cheat a bit and just use the signal toggled()
        https://doc.qt.io/qt-5/qgroupbox.html#toggled

        void MainWindow::on_groupBox_toggled(bool status)
        {
            auto List = ui->groupBox->findChildren<QLineEdit *>();
            for (QLineEdit *line : List ) {
                line->setEnabled( ! status );
            }
        
        }
        
        

        alt text

        Works ok if you tweak the start settings a bit.

        1 Reply Last reply
        3

        1/3

        10 Mar 2020, 06:21

        • Login

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