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. QPushButtom very short question
QtWS25 Last Chance

QPushButtom very short question

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.0k 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.
  • A Offline
    A Offline
    amir734jj
    wrote on last edited by
    #1

    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
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      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
      0
      • A Offline
        A Offline
        amir734jj
        wrote on last edited by
        #3

        SOLVED !!!

        THANKS !!!

        1 Reply Last reply
        0

        • Login

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