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. ui->mybutton setchekable(true) setautoexclusive(false) is autoexclusive!!!!
QtWS25 Last Chance

ui->mybutton setchekable(true) setautoexclusive(false) is autoexclusive!!!!

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 1.4k 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.
  • gfxxG Offline
    gfxxG Offline
    gfxx
    wrote on last edited by A Former User
    #1

    Hello at all..,

    I have a main widow draw with qt5.5 and qtcreator 3.6 ... with some button.
    I would make these button switch On/Off so i try these code:

                ui->btn1->setAutoExclusive(false);
                ui->btn1->setCheckable(true);
               ui->btn2->setAutoExclusive(false);
                ui->btn2->setCheckable(true);
                ui->btn3->setAutoExclusive(false);
                ui->btn3->setCheckable(true);
    
    ....
    ....
    ....
    
                connect(ui->bnt1,SIGNAL(clicked(bool)), this, SLOT(sendBnt1()));
                connect(ui->bnt2,SIGNAL(clicked(bool)), this, SLOT(sendBnt2()));
                connect(ui->bnt3,SIGNAL(clicked(bool)), this, SLOT(sendBnt3()));
    
    
    ......
    .....
    .....
    
    
    void mainwindow::sendBtn1()
    {
        switch (nb1) /* global int variable set "0" to start*/
        {
        case 0:    {ui->bnt1->setDown(true); nbt = 1;}        break;
        case 1:    {ui->bnt1->setDown(false); nbt = 0;}        break;
        default:        break;
        }
    }
    
    ..... for bnt2 and 3 similar void
    
    /*also i use stylesheet  with QPushButton:checked option*/
    ui->eme_button_h->setStyleSheet("QPushButton {image: url(/home/bnt1-off.png);border: 3px solid #8f8f91;border-radius: 20px; background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #FFEEEE, stop: 1 #6F7E81);min-width: 80px;}\n"
                                                "QPushButton:checked {image: url(/home/bnt1-press.png);background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #dadbde, stop: 1 #f6f7fa);border-color: red; border-width: 5px;}\n"
                                                "QPushButton:flat {border: none;}\n"
                                                "QPushButton:default { border-color: navy;}");
    
    

    But the button result autoexclusive .... if click on bnt1 it stay down if re-click go up ... if re-re-click on bnt1 it go down but if click on bnt2 bnt1 go up ?????? is normal

    What can I do to get the desired effect ?

    Use QStateMachine is not desiderable because in real app I have 78 different pushbutton...

    Regards
    Gfxx

    bkt

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      If I make default GUI project
      Place 3 PushButton on mainwindow.
      Select them all, and enable Check-able. (autoexclusive is off default)
      It just works.

      So Im thinking it has something to do with your use of setDown

      1 Reply Last reply
      0
      • gfxxG Offline
        gfxxG Offline
        gfxx
        wrote on last edited by gfxx
        #3

        hi,

        in the last hour i add other 56 push button, some in groupbox some in tabwidget ... no one in mainwindows .... with only:

        ui->mynewbuttoxx->setCheckable(true);
        

        with no other code to support change state .....

        all new button works perfect as I aspect .... only the old in mainwindow not work properly ...

        Not see anythings that indicates my the possible error ..... I need some help ...
        ui->bnt1->setCheckable(true);

        //your code here
        

        but nothings change......

        regards
        Gfxx

        bkt

        1 Reply Last reply
        0
        • gfxxG Offline
          gfxxG Offline
          gfxx
          wrote on last edited by
          #4

          AT These point I try to delete all the old button .... clean pgect ... create new button in qtcreator and reconnect the old signal and slot with new button item.... rebuld..

          MAGICALLY ALL WORKS ....

          N.B. some hour ago I have manually delete all moc. file and .o exstension file in project ......

          Hi at all
          Gfxx

          bkt

          1 Reply Last reply
          1

          • Login

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