Results 1 to 16 of 16

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

Threaded View

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

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

    Quote Originally Posted by anda_skoa View Post
    Consider the first argument to setContextProperty() as equivalent to a QML "id" of the object.
    I think you've already done that with the model.

    Cheers,
    _
    Ok, so there is no way to handle this via signal/slot, since this is what am I trying to do (this code does NOT work) - file UeStatusIndicator.qml, which is called from main.qml:
    Qt Code:
    1. import QtQuick 2.0
    2.  
    3. import si.mikroelektronika 1.0
    4.  
    5. Item
    6. {
    7. id: ueStatusIndicator
    8.  
    9. property string ueParamImageStatusOn
    10. property string ueParamImageStatusOff
    11.  
    12. signal ueSignalDatabaseConnectionChanged(UeTypeDatabaseConnectionStatus status) // from UeStatus
    13.  
    14. state: "ueStatusIndicatorDabaseNotConnected"
    15.  
    16. Image
    17. {
    18. id: ueStatusIndicatorCurrentImage
    19.  
    20. smooth: true
    21.  
    22. fillMode: Image.PreserveAspectFit
    23.  
    24. width: 96
    25. height: 96
    26.  
    27. sourceSize.width: 96
    28. sourceSize.height: 96
    29. } // Image
    30.  
    31. Connections
    32. {
    33. target: ueStatusIndicator
    34.  
    35. onUeSignalDatabaseConnectionChanged:
    36. {
    37. state=(status===UeTypeDatabaseConnectionStatus.CONNECTED):
    38. "ueStatusIndicatorDabaseConnected"?
    39. "ueStatusIndicatorDabaseNotConnected"
    40. }
    41. } // Connections
    42.  
    43. states:
    44. [
    45. State
    46. {
    47. name: "ueStatusIndicatorDabaseConnected"
    48.  
    49. PropertyChanges
    50. {
    51. target: ueStatusIndicatorCurrentImage
    52. source: ueParamImageStatusOn
    53. } // PropertyChanges
    54. }, // State
    55.  
    56. State
    57. {
    58. name: "ueStatusIndicatorDabaseNotConnected"
    59.  
    60. PropertyChanges
    61. {
    62. target: ueStatusIndicatorCurrentImage
    63. source: ueParamImageStatusOff
    64. } // PropertyChanges
    65. } // State
    66. ] // states
    67. } // Item
    To copy to clipboard, switch view to plain text mode 
    Last edited by MarkoSan; 17th September 2015 at 13:59. Reason: updated contents
    Qt 5.3 Opensource & Creator 3.1.2

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.