Results 1 to 16 of 16

Thread: Catching Qt/C++ signal from QML custom Item/code - howto

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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: Catching Qt/C++ signal from QML custom Item/code - howto

    Try changing the signal's signature to have an int instead of the enum.

    Or use the property binding approach.

    Cheers,
    _

  2. #2
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Question Re: Catching Qt/C++ signal from QML custom Item/code - howto

    Quote Originally Posted by anda_skoa View Post
    Try changing the signal's signature to have an int instead of the enum.

    Or use the property binding approach.

    Cheers,
    _
    Ok, but binding works only in QML=>C++ way, not vice versa, as seen in http://doc.qt.io/qt-5/qml-qtqml-binding.html#details, what I need is update QML element based on C++ class member value:
    Detailed Description

    Binding to an Inaccessible Property

    Sometimes it is necessary to bind to a property of an object that wasn't directly instantiated by QML - generally a property of a class exported to QML by C++. In these cases, regular property binding doesn't work. Binding allows you to bind any value to any property.

    For example, imagine a C++ application that maps an "app.enteredText" property into QML. You could use Binding to update the enteredText property like this.

    TextEdit { id: myTextField; text: "Please type here..." }
    Binding { target: app; property: "enteredText"; value: myTextField.text }
    and the last sentence in the mentioned docs states:
    Whenever the text in the TextEdit is updated, the C++ property will be updated also.
    Can you show me please what did you plan to do, since I need contra scenarium.

    Sincerely,
    Marko
    Qt 5.3 Opensource & Creator 3.1.2

  3. #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: Catching Qt/C++ signal from QML custom Item/code - howto

    Quote Originally Posted by MarkoSan View Post
    Ok, but binding works only in QML=>C++ way, not vice versa
    No

    Quote Originally Posted by MarkoSan View Post
    Which is totally irrelevant here since you are not trying to bind a property of a C++ object to an expression.

    Quote Originally Posted by MarkoSan View Post
    what I need is update QML element based on C++ class member value
    Indeed, which is just a plain and simple property binding.
    The "state" property gets bound to an expression using the context property object's "connection status" property.

    Cheers,
    _

  4. #4
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Catching Qt/C++ signal from QML custom Item/code - howto

    Quote Originally Posted by anda_skoa View Post
    No


    Which is totally irrelevant here since you are not trying to bind a property of a C++ object to an expression.


    Indeed, which is just a plain and simple property binding.
    The "state" property gets bound to an expression using the context property object's "connection status" property.

    Cheers,
    _
    Can you give me example please?!?!?!
    Qt 5.3 Opensource & Creator 3.1.2

  5. #5
    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: Catching Qt/C++ signal from QML custom Item/code - howto

    You've done that numerous times already, I am sure
    Qt Code:
    1. state: ueApplicationStatus.m_ueDatabaseConnectionStatus === UeTypeDatabaseConnectionStatus.CONNECTED ?
    2. "ueStatusIndicatorDabaseConnected" : "ueStatusIndicatorDabaseNotConnected"
    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:

    MarkoSan (18th September 2015)

Similar Threads

  1. Catching signal from Mobile Dialpad buttons
    By baluk in forum Qt Programming
    Replies: 1
    Last Post: 27th September 2010, 11:05
  2. Catching exceptions with Qt
    By The_Fallen in forum Qt Programming
    Replies: 6
    Last Post: 30th July 2010, 19:39
  3. Replies: 1
    Last Post: 30th July 2010, 07:23
  4. Qt - catching interrupts
    By rishid in forum Qt Programming
    Replies: 2
    Last Post: 5th February 2008, 14:17
  5. Catching X Events
    By nupul in forum Qt Programming
    Replies: 3
    Last Post: 16th April 2006, 12:43

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
  •  
Qt is a trademark of The Qt Company.