Results 1 to 3 of 3

Thread: How to call a function when i clic a button?

  1. #1
    Join Date
    Jan 2009
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Question How to call a function when i clic a button?

    Yes, i know... very novice.

    Im a C# developer, but i want to get out of dotnet asap. I chose QT and bought the book "C++ GUI Programming with Qt 4, Second Edition".

    reading the book i have a very noob question: How can i clic a button and then call a funcion as result?. i know is very noob but please be nice, im new to QT (started yesterday).

    I was looking at signals and connectios, but this is what i had seen so far:

    One signal can be connected to many slots:

    Many signals can be connected to the same slot:

    A signal can be connected to another signal:

    Connections can be removed:

    But what i want is to connect a signal to a function.

    Thanks!

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to call a function when i clic a button?

    Qt Code:
    1. class MyWidget: public QWidget
    2. {
    3. Q_OBJECT
    4. ...
    5. public:
    6. ...
    7. private slots:
    8. void processMyButtonClick();
    9. ...
    10. };
    11. ...
    12. connect(m_myButton, SIGNAL(clicked()), SLOT(processMyButtonClick()));
    13. ...
    14. void MyWidget::processMyButtonClick()
    15. {
    16. //do my stuff
    17. }
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

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

    trend900 (22nd January 2009)

  4. #3
    Join Date
    Jan 2009
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to call a function when i clic a button?

    Solved.

    Thanks!!

Similar Threads

  1. QPSQL problem
    By LoneWolf in forum Installation and Deployment
    Replies: 60
    Last Post: 4th November 2009, 15:22
  2. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 13:57
  3. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 18:33
  4. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 07:13
  5. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 13:52

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.