Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Custom type Q property issue when derived type assigned

Custom type Q property issue when derived type assigned

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 334 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • RajeeshRaveendranR Offline
    RajeeshRaveendranR Offline
    RajeeshRaveendran
    wrote on last edited by
    #1

    Hi,

    I have derived a class from QObject(say BaseProperty). Then I derived 2 classes from BaseProperty named DProp1 and DProp2.
    All the above 3 classes registerd to QML meta system using qmlRegisterType() API.

    Now i have a complex type class which contain a property with type BaseProperty*

    class MyMainItem : public QObject{
    Q_OBJECT
    Q_PROPRTY(BaseProperty* property READ getProp WRITE setProp)
    ...
    };
    Then I registered this class as follows:
    qmlRegistertType<MyMainItem>( "MyTypes", 1, 0, "MyMainItem");

    In my QML i have added like...

    #import MyTypes 1.0
    MyMainItem {
    property: DProp1 {} /// Causes error
    property: BaseProperty{} /// Fine
    }

    I can't set derived object to Base type property.
    I know it can done in some way similar like

    TextInput{
    validator: IntValidator{bottom: 11; top: 31;} /// Work fine
    OR
    validator: DoubleValidator{bottom: 1.0; top: 2.0;} /// Work fine
    }
    Please help. How to do that?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved