Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    QPushButtom very short question

    General and Desktop
    2
    3
    825
    Loading More Posts
    • 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.
    • A
      amir734jj last edited by

      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()));@
      
      1 Reply Last reply Reply Quote 0
      • K
        koahnig last edited by

        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.

        Vote the answer(s) that helped you to solve your issue(s)

        1 Reply Last reply Reply Quote 0
        • A
          amir734jj last edited by

          SOLVED !!!

          THANKS !!!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post