Results 1 to 5 of 5

Thread: Another signal error message

  1. #1
    Join Date
    Mar 2010
    Location
    Auckland, NZ
    Posts
    114
    Thanks
    8
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Another signal error message

    After my program executes (correctly) I see a long list of error messages. These do not reflect a serious problem, apparently (since the program runs OK) but they are annoying and I'd like to get rid of them.
    All the messages look like this:
    Object::connect: No such signal QLabel::labelClicked(QString)
    Object::connect: (sender name: 'label_hour')
    Object::connect: (receiver name: 'MainWindow')

    with variations of sender name.

    I have extended QLabel to QMyLabel thus:

    #ifndef QMYLABEL_H
    #define QMYLABEL_H

    #include <qlabel.h>
    class QMyLabel: public QLabel
    {
    Q_OBJECT
    public:
    QMyLabel(QWidget *parent = 0);
    signals:
    void labelClicked(QString text);
    private:
    void mousePressEvent (QMouseEvent *event);
    };

    #endif

    and

    QMyLabel::QMyLabel(QWidget *parent) : QLabel(parent)
    {}

    //------------------------------------------------------------------------------------------------------------------
    // Redefines mousePressEvent for QMyLabel, which extends QLabel. This is used to display info about a model parameter.
    //------------------------------------------------------------------------------------------------------------------
    void QMyLabel::mousePressEvent (QMouseEvent *event) {
    event->accept();
    QString sname = objectName().mid(6);
    QString text = "mousePressEvent";
    // Find which label_ sent the signal, and read its text
    for (int k=0; k<parm->nParams; k++) {
    PARAM_SET param = parm->get_param(k);
    if (sname.compare(param.tag) == 0)
    text = param.text;
    }
    emit labelClicked(text);
    }

    In Qt Creator I promote many QLabels to QMyLabel in order to display info about the fields they label.

    Why does this trigger error messages when the program executes?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Another signal error message

    Check that this particular instance has indeed been promoted, e.g. check the generated ui_mainwindow.h file (or whatever yours is called).

    Maybe "label_hour" is still of type QLabel

    Cheers,
    _

  3. #3
    Join Date
    Mar 2010
    Location
    Auckland, NZ
    Posts
    114
    Thanks
    8
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Another signal error message

    Quote Originally Posted by anda_skoa View Post
    Check that this particular instance has indeed been promoted, e.g. check the generated ui_mainwindow.h file (or whatever yours is called).

    Maybe "label_hour" is still of type QLabel

    Cheers,
    _
    Thanks anda_skoa! In fact I had neglected to promote a couple of QLabels, and this helped to confuse me. I now understand my own code (written years ago) better. I am blindly trying to connect all UI objects that have a name starting with "label_", which explains all those error messages, since my UI includes many QLabels that I do not want to promote to QMyLabel. So my new question is how can I detect whether or not a QLabel object has been promoted?

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Another signal error message

    If you mean "how can I detect if a label is of type QMyLabel", then the answer is cast

    Qt Code:
    1. QMyLabel *myLabel = qobject_cast<QMyLabel*>(label);
    2. if (myLabel != 0) {
    3. // label is in fact of type QMyLabel
    4. } else {
    5. // label is not of type QMyLabel
    6. }
    To copy to clipboard, switch view to plain text mode 

    Alternatively
    Qt Code:
    1. if (label->inherits("QMyLabel")) {
    2. }
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  5. The following user says thank you to anda_skoa for this useful post:

    gib (28th October 2013)

  6. #5
    Join Date
    Mar 2010
    Location
    Auckland, NZ
    Posts
    114
    Thanks
    8
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Another signal error message

    Excellent! Thanks a lot

Similar Threads

  1. any way to catch error message from dll in a gui app?
    By lvdong in forum Qt Programming
    Replies: 2
    Last Post: 24th October 2010, 11:49
  2. error message
    By offline in forum Qt Programming
    Replies: 1
    Last Post: 5th November 2009, 15:08
  3. is there any api can send signal/message to other application
    By guchangyuan in forum Qt Programming
    Replies: 7
    Last Post: 27th July 2009, 10:04
  4. what`s means this Error Message?
    By blm in forum Qt Programming
    Replies: 2
    Last Post: 15th September 2008, 17:58
  5. Qtopia-arm error message ?
    By anafor2004 in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 25th March 2008, 09:29

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.