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. accessing multiple pushbutton objects from a loop
Forum Updated to NodeBB v4.3 + New Features

accessing multiple pushbutton objects from a loop

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 205 Views 2 Watching
  • 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.
  • D Offline
    D Offline
    dencla54
    wrote on last edited by
    #1

    I nave an application the I have created multiple push buttons in a group. I need to change the background color and text based on a global bit and a button selection to change the text. Below is the code for one button, but I need to extend the changes to 64 buttons.

    unsigned long long gagset = 0, gagset2 = 0;
    bool highgag = false;

    void ToolsetPanel::on_Gag_PB_1_clicked()
    {
    if(highgag == true){
    ui->Gag_PB_1->setText("65");
    }
    else {
    ui->Gag_PB_1->setText("1");
    }

    ui->Gag_PB_1->setStyleSheet(colorButton(gagset & 1));
    
    if(gagset && 1 == true) gagset &= ~1; else gagset |= 1;
    

    }

    void ToolsetPanel::on_Gag_PB_65_clicked()
    {
    if(highgag == true){
    ui->Gag_PB_65->setText("1-64");
    highgag = false;
    }
    else
    {
    ui->Gag_PB_65->setText("65-128");
    highgag = true;
    }
    }

    When tool 65 is selected in need to change the values of all the buttons and the backgrounds if the button has been previously selected according to the bit values of highgag2;

    I hope someone can help me with this. I can individually address each button, but it would be better if I could access them as a group.

    dencla

    Pl45m4P 1 Reply Last reply
    0
    • D dencla54

      I nave an application the I have created multiple push buttons in a group. I need to change the background color and text based on a global bit and a button selection to change the text. Below is the code for one button, but I need to extend the changes to 64 buttons.

      unsigned long long gagset = 0, gagset2 = 0;
      bool highgag = false;

      void ToolsetPanel::on_Gag_PB_1_clicked()
      {
      if(highgag == true){
      ui->Gag_PB_1->setText("65");
      }
      else {
      ui->Gag_PB_1->setText("1");
      }

      ui->Gag_PB_1->setStyleSheet(colorButton(gagset & 1));
      
      if(gagset && 1 == true) gagset &= ~1; else gagset |= 1;
      

      }

      void ToolsetPanel::on_Gag_PB_65_clicked()
      {
      if(highgag == true){
      ui->Gag_PB_65->setText("1-64");
      highgag = false;
      }
      else
      {
      ui->Gag_PB_65->setText("65-128");
      highgag = true;
      }
      }

      When tool 65 is selected in need to change the values of all the buttons and the backgrounds if the button has been previously selected according to the bit values of highgag2;

      I hope someone can help me with this. I can individually address each button, but it would be better if I could access them as a group.

      dencla

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #2

      @dencla54 said in accessing multiple pushbutton objects from a loop:

      I can individually address each button, but it would be better if I could access them as a group.

      Put them in a QButtonGroup or some container like QVector and iterate them


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      D 1 Reply Last reply
      5
      • Pl45m4P Pl45m4

        @dencla54 said in accessing multiple pushbutton objects from a loop:

        I can individually address each button, but it would be better if I could access them as a group.

        Put them in a QButtonGroup or some container like QVector and iterate them

        D Offline
        D Offline
        dencla54
        wrote on last edited by
        #3

        @Pl45m4 Thanks I believe that I have it.

        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 Extensions
        • Unsolved