Results 1 to 7 of 7

Thread: Question about QMetaMethod

  1. #1
    Join Date
    Jan 2006
    Posts
    156
    Thanked 12 Times in 12 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Question about QMetaMethod

    Hi,

    I want for Qt widgets list all signals with parameters. For this I use :
    Qt Code:
    1. QLineEdit *line = new QLineEdit;
    2. for(int i=0; i<line->metaObject()->methodCount(); i++)
    3. {
    4. QMetaMethod meta = line->metaObject()->method( i );
    5. if( meta.methodType() == QMetaMethod::Signal )
    6. qDebug() << meta.signature() << meta.parameterTypes() << meta.parameterNames();
    7. }
    To copy to clipboard, switch view to plain text mode 
    The result of the example above is :
    Qt Code:
    1. destroyed(QObject*) ("QObject*") ("")
    2. destroyed() () ()
    3. customContextMenuRequested(QPoint) ("QPoint") ("pos")
    4. textChanged(QString) ("QString") ("")
    5. textEdited(QString) ("QString") ("")
    6. cursorPositionChanged(int,int) ("int", "int") ("", "")
    7. returnPressed() () ()
    8. editingFinished() () ()
    9. selectionChanged() () ()
    10. lostFocus() () ()
    To copy to clipboard, switch view to plain text mode 
    The problem is for textChanged, textEdited etc. Indeed the type parameters is present but not the names whereas for customContextMenuRequested the name "pos" is present.

    Then why for certain signals the names are present and for others not ?
    I would like to have all the names !

    Thanks
    QDevelop, an complete Integrated Development Environment for Qt 4: http://qdevelop.org

  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: Question about QMetaMethod

    Quote Originally Posted by jlbrd
    Then why for certain signals the names are present and for others not ?
    qlineedit.h:
    Qt Code:
    1. ...
    2. Q_SIGNALS:
    3. void textChanged(const QString &);
    4. ...
    To copy to clipboard, switch view to plain text mode 

    qwidget.h:
    Qt Code:
    1. Q_SIGNALS:
    2. void customContextMenuRequested(const QPoint &pos);
    To copy to clipboard, switch view to plain text mode 

    Now you see why?

  3. #3
    Join Date
    Jan 2006
    Posts
    156
    Thanked 12 Times in 12 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Question about QMetaMethod

    Thanks you,
    Yes I understand why.
    My error it is that in Documentation, the names are present. Examble, textChanged appear :
    Qt Code:
    1. void QLineEdit::textChanged ( const QString & text )
    To copy to clipboard, switch view to plain text mode 

    Certain parameters are regarded as "useless" since the name is not present in the header ?
    QDevelop, an complete Integrated Development Environment for Qt 4: http://qdevelop.org

  4. #4
    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: Question about QMetaMethod

    Quote Originally Posted by jlbrd
    Certain parameters are regarded as "useless" since the name is not present in the header ?
    No, you just don't have to provide parameter names in headers.

  5. #5
    Join Date
    Jan 2006
    Posts
    156
    Thanked 12 Times in 12 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Question about QMetaMethod

    You are right. It is not necessary to put the names of the parameters but :

    1. Why write certain names and not others on headers.
    2. Especially why create a function which is not always useful ( QMetaMethod:: parameterNames()).
    QDevelop, an complete Integrated Development Environment for Qt 4: http://qdevelop.org

  6. #6
    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: Question about QMetaMethod

    Quote Originally Posted by jlbrd
    Why write certain names and not others on headers.
    Because there are many developers and some write signal parameter names and some don't? I think that simply nobody thought that somebody might need them.

    Quote Originally Posted by jlbrd
    Especially why create a function which is not always useful ( QMetaMethod:: parameterNames()).
    Actually all functions aren't always useful.

    If you really concerned about this, send a suggestion to the Trolls that they should add missing parameter names or even create a patch for it.

  7. #7
    Join Date
    Jan 2006
    Posts
    156
    Thanked 12 Times in 12 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Question about QMetaMethod

    Ok thank you,for your information, I explain why I need some (even if you cannot help me !) :

    I work on QIde, a IDE for Qt4. With a right click, one will be able to create a subclass of a form (ui). In a dialog (see screenshot), I list signals for each widgets. When the user valid the dialog, each items checked are created on a new implementation file with his name, parameter types and names. It is for that that I need the names!

    Thanks,
    Attached Images Attached Images
    QDevelop, an complete Integrated Development Environment for Qt 4: http://qdevelop.org

Similar Threads

  1. QTextEdit simple question
    By Marcopolo in forum Qt Tools
    Replies: 4
    Last Post: 11th October 2007, 00:01
  2. Beginner C++ question
    By masoroso in forum General Programming
    Replies: 2
    Last Post: 19th April 2006, 14:15
  3. Replies: 6
    Last Post: 19th March 2006, 18:41
  4. Basic question on new and delete
    By jcr in forum General Programming
    Replies: 25
    Last Post: 14th February 2006, 15:09
  5. QTextEdit Qt4: simple question
    By TheKedge in forum Qt Programming
    Replies: 4
    Last Post: 18th January 2006, 12:03

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.