[SOLVED] How do i make a QToolButton to work similiar to Bold button in text editors?

  • How can I make a QToolButton work in a similar fashion to the Bold button in text editing software? I have tried using the setCheckable(true) way, but it worked only for the first press. Afterwards it didn't work anymore.

    Thank you in advance.

  • what version of Qt and OS do you use?

  • Qt 4.8.4 Windows 7

  • @b1snak3
    your thread title is useless. Please change to have something triggering an understanding without opening it.

  • Please, give more details about your problem. May be post some related code

  • @ callButton = new QToolButton;
    // Connect
    connect(callButton, SIGNAL(clicked()), this, SLOT(callUser()));

    // the callUser slot
    void PMsgWindow::callUser() {

        callAct->setToolTip("End call");

    // the 2nd connect for the deactivation of the press
    // this is in the callUser slot
    connect(callButton, SIGNAL(clicked()), this, SLOT(endCall()));

    // the endcall slot
    void PMsgWindow::endCall() {

    this code works only for the 1st click. then it doesn't react in the same way.

  • do you make @disconnect(callButton, SIGNAL(clicked()), this, SLOT(callUser()));@

    at callUser() slot?

    Also instead of using 2 slots for clicked() signal, you can make one slot e.g.
    @void call(bool checked);@

    and connect clicked(bool) signal to it.

  • also with

    you should not manually call setChecked(bool) method.

  • that works, thank you. tried the clicked(bool) earlier but didn't make it to work. the disconnect approach works.

Log in to reply

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