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?
Forum Update on Monday, May 27th 2025

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 583 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 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.

    JonBJ 1 Reply Last reply
    0
    • S Savio Brilhante

      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.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #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
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by mrjj
        #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

        • Login

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