Results 1 to 5 of 5

Thread: not emiting signal

  1. #1
    Join Date
    Oct 2007
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default not emiting signal

    Hi, I'm trying to make a simplest program people have ever seen...

    Here it is main.cpp:
    Qt Code:
    1. #include <QApplication>
    2. #include <QDialog>
    3. #include "chala.h"
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication app(argc, argv);
    8.  
    9. Ui::chala ui;
    10. QDialog *dialog = new QDialog;
    11. ui.setupUi(dialog);
    12. dialog->show();
    13. return app.exec();
    14. }
    To copy to clipboard, switch view to plain text mode 
    chala.h:

    Qt Code:
    1. #ifndef CHALA_H
    2. #define CHALA_H
    3. #include <QDialog>
    4. #include "ui_chala.h"
    5.  
    6. class chala : public QDialog, public Ui::chala
    7. {
    8. Q_OBJECT
    9.  
    10. public:
    11. chala(QWidget *parent = 0);
    12.  
    13. public slots:
    14. void srutututu();
    15. void majtki();
    16.  
    17. };
    18. #endif
    To copy to clipboard, switch view to plain text mode 



    and chala.cpp :

    Qt Code:
    1. #include <QtGui>
    2.  
    3. #include "chala.h"
    4.  
    5. chala::chala(QWidget *parent)
    6. : QDialog(parent)
    7. {
    8. setupUi(this);
    9.  
    10. connect(pushButton, SIGNAL(clicked()), this, SLOT(srutututu()));
    11. connect(pushButton_2, SIGNAL(clicked()), this, SLOT(majtki()));
    12.  
    13. }
    14. void chala::srutututu()
    15. {
    16. qDebug() << "slot 1";
    17. lineEdit->setText("new content");
    18. }
    19. void chala::majtki()
    20. {
    21. label_2->setText("elo 6700");
    22. }
    To copy to clipboard, switch view to plain text mode 

    and 'ive done a simpliest window in designer with 4 pushbuttons lineEdit and label.... :

    piece of ui_chala.cpp
    Qt Code:
    1. QObject::connect(pushButton, SIGNAL(clicked()), lineEdit, SLOT(hide()));
    2. QObject::connect(pushButton_2, SIGNAL(clicked()), lineEdit, SLOT(show()));
    To copy to clipboard, switch view to plain text mode 

    When i'm creating signal slot show/hide in designer everything works fine!
    But when i'm trying to use my own slot(srutututu() and majtki()) actually nothing happens..
    in my opinion signal is even not emited. So what am i doing wrong ?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: not emiting signal

    You don't instantiate that class in main(). It should be:
    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication app(argc, argv);
    4.  
    5. chala dlg;
    6. dlg.show();
    7.  
    8. return app.exec();
    9. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: not emiting signal

    Yes... "majtki" is a very good slot name, I'll have to remember that one...

  4. #4
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: not emiting signal

    me too...
    We can't solve problems by using the same kind of thinking we used when we created them

  5. #5
    Join Date
    Oct 2007
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: not emiting signal

    it should be 'srutututu majtki z drutu' ;)
    thanks for your help, it works now :)

Similar Threads

  1. how to emit signal in a static function ?
    By cxl2253 in forum Qt Programming
    Replies: 32
    Last Post: 7th July 2016, 22:36
  2. Replies: 3
    Last Post: 15th April 2007, 20:16
  3. Replies: 2
    Last Post: 17th May 2006, 22:01
  4. no such signal QListBox::currentChanged()
    By jopie bakker in forum Newbie
    Replies: 2
    Last Post: 2nd March 2006, 16:17
  5. Emiting signal, which NOT connected to any slots
    By krivenok in forum Qt Programming
    Replies: 7
    Last Post: 27th February 2006, 17:32

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.