Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Group of Checkboxes
Qt 6.12 LTS is out! See what's new in the release blog

Group of Checkboxes

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.1k 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.
  • E Offline
    E Offline
    erytcg
    wrote on last edited by erytcg
    #1

    Hello I have 16 checkboxes and they have similar task to hide graph on qcustomplot can I do this in one method?

    void checkBoxStateChanged(int state) //1
    	{
    	    if(state)
    	    {  
    	      plot->graph(0)->setVisible(false);
    	    }
    	    else
    	    {
    	       plot->graph(0)->setVisible(true);
    	    }  
    	    
    	};
    
    1 Reply Last reply
    0
    • S Offline
      S Offline
      samdol
      wrote on last edited by samdol
      #2

      Create QButtonGroup and add buttons to it. Then connect buttonGroup to slot function which has functions for all buttons.
      In this way you don't have to create slot functions for each button. You need only one slot function for all buttons.

       buttonGroup = new QButtonGroup(this);
       buttonGroup->setExclusive(false);
       buttonGroup->addButton(textButton, InsertTextButton);
       connect(buttonGroup, SIGNAL(buttonClicked(int)),
               this, SLOT(buttonGroupClicked(int)));
      
       void buttonGroupClicked(int id)
       {
           QList<QAbstractButton *> buttons = buttonGroup->buttons();
           foreach (QAbstractButton *button, buttons) {
           if (buttonGroup->button(id) != button)
               button->setChecked(false);
           }
           if (id == InsertTextButton) {
           } else {
           }
       }
      
      1 Reply Last reply
      0

      • Login

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