Results 1 to 15 of 15

Thread: Custom signal and slots

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2011
    Posts
    19
    Thanks
    2
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Custom signal and slots

    Hello again,


    I am trying to make a simple application where when I click a button the count is displayed in the QLineEdit. But I cant get the signal going. I have read different documentations but for custom signal and slots everywhere I see I get a different account or method.

    I am posting my files. Please help me understand the concept

    click.h
    Qt Code:
    1. #ifndef CLICK_H
    2. #define CLICK_H
    3.  
    4. #include<QMainWindow>
    5. #include<QLineEdit>
    6. #include<QPushButton>
    7.  
    8. namespace Ui
    9. {
    10. class click_me;
    11. }
    12.  
    13.  
    14. class click_me:public QMainWindow
    15. {
    16. Q_OBJECT
    17. public:
    18. click_me(QWidget *Parent=0);
    19. signals:
    20. void click1(int);
    21. private slots:
    22. void disp();
    23. private:
    24. Ui::click_me *ui;
    25. private:
    26. QLineEdit *l1;
    27. };
    28. #endif
    To copy to clipboard, switch view to plain text mode 

    click.cpp
    Qt Code:
    1. #include"click.h"
    2. #include"ui_click.h"
    3.  
    4. int count=0;
    5.  
    6. click_me::click_me(QWidget *parent):QMainWindow(parent),ui(new Ui::click_me)
    7. {
    8. ui->setupUi(this);
    9.  
    10. //int count=0;
    11. connect(ui->p1,SIGNAL(click1(int)),ui->l1,SLOT(disp(int)));
    12. }
    13.  
    14. void click_me::disp(int)
    15. {
    16.  
    17. //emit click1(count);
    18. count = count +1;
    19.  
    20. QString s=QString::number(count);
    21.  
    22.  
    23. ui->l1->setText(s);
    24. }
    25.  
    26. //int click_me::click1(int co)
    27. //{
    28. //
    29. // emit click1();
    30. //return co;
    31.  
    32. //}
    To copy to clipboard, switch view to plain text mode 
    click.zip

    I am just unable to understand how do I pass parameters in the signal and even if I am passing one.... How do I go about declaring, defining and passing them.

    Clearing its a off day for me :-\
    Last edited by amitahire; 27th June 2012 at 11:17.

Similar Threads

  1. Signal/Slots, Where can i use it?
    By Tio in forum Newbie
    Replies: 2
    Last Post: 25th May 2010, 01:36
  2. Signal and Slots
    By waynew in forum Newbie
    Replies: 3
    Last Post: 20th November 2009, 03:50
  3. signal and slots
    By vermarajeev in forum Qt Programming
    Replies: 4
    Last Post: 16th October 2007, 08:31
  4. Signal and slots
    By villy in forum Qt Programming
    Replies: 1
    Last Post: 12th January 2007, 10:10
  5. Problem with Signal and Slots
    By Kapil in forum Installation and Deployment
    Replies: 2
    Last Post: 10th February 2006, 08:51

Tags for this Thread

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.