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.
  • P Offline
    P Offline
    PopQt
    wrote on 24 Apr 2018, 06:15 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.

    V 1 Reply Last reply 24 Apr 2018, 06:33
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 24 Apr 2018, 06:29 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
      • P PopQt
        24 Apr 2018, 06:15

        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.

        V Offline
        V Offline
        Venkatesh V
        wrote on 24 Apr 2018, 06:33 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.

        P 1 Reply Last reply 24 Apr 2018, 07:04
        2
        • G Offline
          G Offline
          Geeva
          wrote on 24 Apr 2018, 06:55 last edited by
          #4
          This post is deleted!
          1 Reply Last reply
          0
          • V Venkatesh V
            24 Apr 2018, 06:33

            @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.

            P Offline
            P Offline
            PopQt
            wrote on 24 Apr 2018, 07:04 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

            V 2 Replies Last reply 24 Apr 2018, 07:12
            0
            • P PopQt
              24 Apr 2018, 07:04

              @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

              V Offline
              V Offline
              Venkatesh V
              wrote on 24 Apr 2018, 07:12 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
              • P PopQt
                24 Apr 2018, 07:04

                @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

                V Offline
                V Offline
                Venkatesh V
                wrote on 24 Apr 2018, 07:22 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

                1/7

                24 Apr 2018, 06:15

                • Login

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