Results 1 to 3 of 3

Thread: QPushButton click

  1. #1
    Join Date
    Oct 2010
    Posts
    12
    Thanks
    6
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QPushButton click

    Hi, there.
    I got little problem:
    i connected QPushButton clicked() signal to my custom slot:

    Qt Code:
    1. QObject::connect( ui->pushButton, SIGNAL(clicked()), this, SLOT(on_pushButton_clicked()));
    To copy to clipboard, switch view to plain text mode 
    but when I click on pushButton signal clicked() is sent twice ( on_pushButton_clicked() is called twice).
    Any ideas?

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QPushButton click

    The slot is connected twice.
    Once by auto-connect (because of the name on_OBJECTNAME_SIGNALNAME), and once by you (when you call connect)

    LE: I couldn't find the reference for auto connect, only this (but there isn't much to say anyway)
    To solve your issue, use a different name and QObject::connect(...), or use the name-ing convention and the signal will be auto-connected with the slot (remember two connections between one signal and one slot means two executions of the slot for each time the signal is emitted)
    Last edited by Zlatomir; 29th November 2010 at 15:49.

  3. The following user says thank you to Zlatomir for this useful post:

    qutron (29th November 2010)

  4. #3
    Join Date
    Oct 2010
    Posts
    12
    Thanks
    6
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QPushButton click

    OH, I got it. Thanks!!

Similar Threads

  1. Round Icon shaped QPushButton Click event
    By kcsomisetty in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 16th June 2010, 07:52
  2. Replies: 7
    Last Post: 26th August 2009, 08:21
  3. QPushButton deleting itself on click
    By Cruz in forum Qt Programming
    Replies: 4
    Last Post: 23rd January 2009, 10:18
  4. Replies: 2
    Last Post: 12th January 2009, 00:24
  5. QPushButton on Shift+Click?
    By vishal.chauhan in forum Qt Programming
    Replies: 3
    Last Post: 9th September 2008, 11:00

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.