Results 1 to 20 of 22

Thread: QPushButton and connect problem(((

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #14
    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 and connect problem(((

    Yes, what i said remains valid, but in your particular case you don't pass anything - because the clicked signal has void parameters and if the slot (member function) has default arguments (void setTxt(QString txt = "hi!"); ) so it can be called with void parameter ( just setTxt() ) - and it will just use the default value.

    So the connect statement will be:
    Qt Code:
    1. QObject::connect(btn, SIGNAL(clicked()), btn, SLOT(setTxt())); //no QString here (it will use the default)
    To copy to clipboard, switch view to plain text mode 
    //Read the documentation for signal and slots (i gave you a link in my first post)

    LE: Also the setTxt slot should not emit clicked signal (you end up with an infinite loop) so delete/comment the line: emit clicked(); from void mybtn::setTxt(QString txt) {...}
    Last edited by Zlatomir; 13th June 2011 at 13:26.

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

    make (14th June 2011)

Similar Threads

  1. Replies: 2
    Last Post: 2nd May 2011, 08:10
  2. connect a QPushButton matrix with a function
    By harmodrew in forum Newbie
    Replies: 6
    Last Post: 6th August 2010, 11:11
  3. connect a qpushbutton a slot
    By Lycus HackerEmo in forum Newbie
    Replies: 13
    Last Post: 29th March 2010, 09:14
  4. QSS problem on a QPushButton
    By ber0y in forum Newbie
    Replies: 6
    Last Post: 21st July 2009, 07:56
  5. QPushButton problem
    By sincnarf in forum Qt Programming
    Replies: 4
    Last Post: 20th August 2007, 21:02

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
  •  
Qt is a trademark of The Qt Company.