Results 1 to 4 of 4

Thread: QML's autogenerated signal handlers with C++ declared signals

  1. #1
    Join Date
    May 2013
    Posts
    1
    Thanked 1 Time in 1 Post

    Default QML's autogenerated signal handlers with C++ declared signals

    Hey all,

    I have a program that I’m working on which uses QML. I’m relatively new to it. I’m finding some features are extremely useful and others are rather confusing. Currently, I’m trying to work with signals which are declared in my “workhorse” class (a QThread which processes data) and QML’s signal handlers that are supposed to be automatically created for them.

    The problem is that my QML doesn’t seem to see them. Essentially, I’m expecting it to simply look like this:

    Qt Code:
    1. class WorkHorse : public QThread
    2. {
    3. //...header code...
    4.  
    5. signals:
    6. void myValueChanged();
    7.  
    8. //...more header code...
    9. }
    10.  
    11. //...QML initializations...
    12. //...QML file beginning...
    13. Item{
    14. //...QML code...
    15.  
    16. onMyValueChanged: someOtherItem.text = someValue;
    17.  
    18. //...More QML code...
    19. }
    To copy to clipboard, switch view to plain text mode 


    Most everything else works in the interactions between QML and my workhorse but all I get is red squigglies for the “onMyValueChanged” part of my code. It hasn’t made it or can’t see it. If I type “workHorse.” and hit CTRL+Space the intellisense will show me “onMyValueChanged” as an option. If I choose it, however, “workHorse” gets redsquigglied. Deleting “workHorse” gets me red squigglies on the signal handler name.

    If you guys could help me change what I need to change I’d appreciate it. Perhaps some includes in the project files or adding Q_INVOKABLE to something or rebuilding or qmake… I’m just not sure what I’m missing. Thanks.

  2. The following user says thank you to CHerit for this useful post:


  3. #2
    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: QML's autogenerated signal handlers with C++ declared signals

    If you want to have "onMyValueChanged" signal handler in element "Item" then signal "myValueChanged" would have been emitted by QQuickItem and not a QThread subclass. Your code construction doesn't make sense. It would be better if you provided description of what the ultimate effect that you want to achieve is and we will suggest an approach to reach your goal.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. The following user says thank you to wysota for this useful post:


  5. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QML's autogenerated signal handlers with C++ declared signals

    Quote Originally Posted by wysota View Post
    If you want to have "onMyValueChanged" signal handler in element "Item" then signal "myValueChanged" would have been emitted by QQuickItem and not a QThread subclass.
    Doesn't have to be a QQuickItem subclass, QThread is OK but the QML code needs an instance of that type.
    E.g.something like

    Qt Code:
    1. Item {
    2. WorkHorse {
    3. onMyValueChanged: ...
    4. }
    5. }
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

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


  7. #4
    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: QML's autogenerated signal handlers with C++ declared signals

    Quote Originally Posted by anda_skoa View Post
    Doesn't have to be a QQuickItem subclass,
    I meant commenting the existing code, not that you can't do it using composition.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. The following user says thank you to wysota for this useful post:


Similar Threads

  1. [Signals & Slots] Custom class' signal not detected
    By Mr_Cloud in forum Qt Programming
    Replies: 5
    Last Post: 26th July 2012, 10:35
  2. Replies: 0
    Last Post: 26th September 2011, 23:14
  3. Problem with signal handlers
    By chiru in forum Qt Quick
    Replies: 0
    Last Post: 11th November 2010, 07:57
  4. Properly close database handlers
    By ruben.rodrigues in forum Newbie
    Replies: 5
    Last Post: 23rd September 2010, 16:10
  5. Mapping menu actions to handlers
    By xtal256 in forum Qt Programming
    Replies: 1
    Last Post: 25th August 2010, 07:41

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.