QPushButtom very short question



  • I have two QPushButtom one is to set text to italic another is to bold
    They work fine when I click on either of them and they stay clicked but when I want to click on either of them for the second time so they will unlicked so then set text to not iatlic or not bold , what should I do ?

    @ Italic->setCheckable(true);
    Bold->setCheckable(true);

    connect(Italic,SIGNAL(clicked()),this,SLOT(setItalic()));
    connect(Bold,SIGNAL(clicked()),this,SLOT(setBold()));
    
    connect(Italic,SIGNAL(released()),this,SLOT(setNotItalic()));
    connect(Bold,SIGNAL(released()),this,SLOT(setNotBold()));@

  • Moderators

    You can use the "font property":http://qt-project.org/doc/qt-5.0/qtwidgets/qwidget.html#font-prop to check the current setting and set with setFont.

    You need to use only one connect per button. Both the clicked and released signals are emitted each time you have pressed the button. I assume that released is called first and then your clicked routine. That would explain why you see only one way.
    However, when using a debugger and setting a break point you will find out easily.

    Note: I did not check this, but at least my comment summarizes what I do next.



  • SOLVED !!!

    THANKS !!!


Log in to reply
 

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