Results 1 to 6 of 6

Thread: QObject dynamic properties and QML binding

  1. #1
    Join Date
    Jun 2011
    Posts
    56
    Thanks
    7
    Qt products
    Qt4

    Default QObject dynamic properties and QML binding

    Say I have this:

    Qt Code:
    1. Rectangle {
    2. width: object.dynamicProperty
    3. }
    To copy to clipboard, switch view to plain text mode 

    If dynamicProperty changes no dynamicPropertyChanged signal will be issued, hence width won't change. Is it possible to somehow simulate a NOTIFY signal for a dynamic QObject property?

  2. #2
    Join Date
    Nov 2010
    Posts
    82
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QObject dynamic properties and QML binding

    what kind of object is "object" c++, custom qml,... ?

  3. #3
    Join Date
    May 2009
    Location
    Canada
    Posts
    163
    Thanks
    7
    Thanked 20 Times in 20 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows Android

    Default Re: QObject dynamic properties and QML binding

    If dynamicProperty changes no dynamicPropertyChanged signal will be issued, hence width won't change.
    Are you sure, as in, you've conclusively demonstrated this in your working code? From the docs:

    The property value is automatically kept up to date if the other properties or data values change.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: QObject dynamic properties and QML binding

    The value is kept updated only if a notification signal is sent by the C++ object containing the property.

    @ugluk: Why do you need a dynamic property to be reflected in QML? Can't you use a real property instead?
    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.


  5. #5
    Join Date
    Jun 2011
    Posts
    56
    Thanks
    7
    Qt products
    Qt4

    Default Re: QObject dynamic properties and QML binding

    No, I can't. I thought that there perhaps exists a way to send a dynamic signal. I think that dynamic properties would fit well with a scripting language (which is also dynamic).

    "object" is a C++ object (inheriting QObject).

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: QObject dynamic properties and QML binding

    Why can't you use real properties?
    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.


Similar Threads

  1. Dynamic QML Property Binding
    By EMCEE in forum Qt Quick
    Replies: 1
    Last Post: 30th August 2012, 12:51
  2. QObject, properties
    By Archa4 in forum Newbie
    Replies: 8
    Last Post: 11th February 2011, 09:05
  3. Replies: 1
    Last Post: 20th January 2011, 18:17
  4. dynamic properties
    By Hogwarts in forum Qt Programming
    Replies: 1
    Last Post: 3rd May 2010, 17:37
  5. Saving properties of a QObject based class
    By ghorwin in forum Qt Programming
    Replies: 1
    Last Post: 15th April 2007, 02:26

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.