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. Click not working for QPushButton
Forum Updated to NodeBB v4.3 + New Features

Click not working for QPushButton

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 2.8k Views 2 Watching
  • 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.
  • PopQtP Offline
    PopQtP Offline
    PopQt
    wrote on last edited by
    #1

    Re: [[SOLVED] QPushButton. I click on the button](but nothing not happend.)

    Here is my code,
    QPushButton *textBtnWin;
    textBtnWin = new QPushButton(parent);
    connect(textBtnWin, SIGNAL (clicked()), this, SLOT (handleButton()));

    handleButton(void) {
    blnBtnPressed = !blnBtnPressed;
    qDebug() << blnBtnPressed;
    }

    for some buttons, the click is not working. In fact the mouse hover also does no changes for these buttons.

    Venkatesh VV 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Please show real code. :)
      Also if some buttons dont work and some do, it means
      you have some sort of bug. (as slot works then)

      1 Reply Last reply
      3
      • PopQtP PopQt

        Re: [[SOLVED] QPushButton. I click on the button](but nothing not happend.)

        Here is my code,
        QPushButton *textBtnWin;
        textBtnWin = new QPushButton(parent);
        connect(textBtnWin, SIGNAL (clicked()), this, SLOT (handleButton()));

        handleButton(void) {
        blnBtnPressed = !blnBtnPressed;
        qDebug() << blnBtnPressed;
        }

        for some buttons, the click is not working. In fact the mouse hover also does no changes for these buttons.

        Venkatesh VV Offline
        Venkatesh VV Offline
        Venkatesh V
        wrote on last edited by
        #3

        @PopQt

        Hi,
        Is Your handleButton() function is declared as public slots??
        If it is normal public function you cant connect to the signal by above connect statement.

        PopQtP 1 Reply Last reply
        2
        • G Offline
          G Offline
          Geeva
          wrote on last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • Venkatesh VV Venkatesh V

            @PopQt

            Hi,
            Is Your handleButton() function is declared as public slots??
            If it is normal public function you cant connect to the signal by above connect statement.

            PopQtP Offline
            PopQtP Offline
            PopQt
            wrote on last edited by
            #5

            @Venkatesh-V No I need it as private slot() because I use this class as base and create many buttons.
            Still, I tried it making as public slot() but it didn't work

            Venkatesh VV 2 Replies Last reply
            0
            • PopQtP PopQt

              @Venkatesh-V No I need it as private slot() because I use this class as base and create many buttons.
              Still, I tried it making as public slot() but it didn't work

              Venkatesh VV Offline
              Venkatesh VV Offline
              Venkatesh V
              wrote on last edited by
              #6

              @PopQt

              Can you please share some code snippet?? so that its easy to identify what is the actual problem

              1 Reply Last reply
              1
              • PopQtP PopQt

                @Venkatesh-V No I need it as private slot() because I use this class as base and create many buttons.
                Still, I tried it making as public slot() but it didn't work

                Venkatesh VV Offline
                Venkatesh VV Offline
                Venkatesh V
                wrote on last edited by
                #7

                @PopQt

                private or public slots have no significance with Qt C++ environment if you are using slots in the context of signal-to-slot communication. If you are interested to call this slots as normal member function then public/private is applicable. Also if you are trying to call the slots from QML environment, then slots need to be public only.

                1 Reply Last reply
                1

                • Login

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