Results 1 to 9 of 9

Thread: How to declare a function for click button event

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2010
    Posts
    34
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to declare a function for click button event

    how should I edit these tags...I already used @ tags but its not working ,what I hav to put before these tags ???
    Regards:

    Prajnaranjan Das
    e mail: prajnaranjan.das@gmail.com

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: How to declare a function for click button event

    E.g.:

    [code]int i = 0;
    i++;
    if (i == 1)
    quit();[/code]

  3. #3
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How to declare a function for click button event

    Qt Code:
    1. class ButtonLayout : public QWidget
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. ButtonLayout(QWidget *parent = 0);
    7. QLabel *lblImage;
    8. //add remaining class members
    9. };
    10. ButtonLayout::ButtonLayout(QWidget *parent)
    11. : QWidget(parent)
    12. {
    13. QPushButton *btn1 = new QPushButton("IMAGE");
    14.  
    15. connect(btn1,SIGNAL(clicked()),this,SLOT(openImage()));
    16.  
    17. QVBoxLayout *layout = new QVBoxLayout;
    18. layout->addWidget(btn1);
    19. setLayout(layout);
    20.  
    21. //add like this
    22. lblImage = new QLabel;
    23. lblImage->setPixmap(":/images/Resource/photo.JPG");
    24. }
    25.  
    26. void ButtonLayout::openImage()
    27. {
    28. lblImage->show();
    29. }
    To copy to clipboard, switch view to plain text mode 

    it all depends on ur need. as our Qt experts said, u should start studying QtDoc

    Bala

Similar Threads

  1. How to declare SLOT as a parameter to member function?
    By QPlace in forum Qt Programming
    Replies: 2
    Last Post: 17th July 2018, 00:41
  2. Replies: 4
    Last Post: 27th November 2009, 13:00
  3. Replies: 4
    Last Post: 21st March 2009, 13:51
  4. Replies: 2
    Last Post: 11th January 2009, 23:24
  5. Why do i need to declare a function as a slot?
    By cbarmpar in forum Qt Programming
    Replies: 2
    Last Post: 31st August 2008, 20:38

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.