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



  • 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


  • Qt Champions 2016

    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



  • 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



  • 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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.