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. [solved] Derived Component?
Forum Updated to NodeBB v4.3 + New Features

[solved] Derived Component?

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 989 Views 1 Watching
  • 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.
  • D Offline
    D Offline
    digorydoo
    wrote on 14 May 2014, 09:39 last edited by
    #1

    I'm new to QML/Qt. I basically want to customize a Button from QtQuick.Controls. I already know I can create my own component by creating a MyButton.qml and add an "Item" and put a Button into the Item.
    @
    import QtQuick 2.2
    import QtQuick.Controls 1.1
    Item
    {
    property alias text: btn.text;
    property alias iconSource: btn.iconSource;

    Button
    {
        id: btn;
    }
    

    }
    @

    However, it seems like I have to create property aliases for all the existing properties in Button, and I have to redefine the signals as well. Is this true, or am I missing something? How can I derive my component from an existing component, inheriting all properties and signals?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on 14 May 2014, 11:46 last edited by
      #2

      There is no need to put the Button in an Item. You can directly use Button itself as the root component.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        digorydoo
        wrote on 14 May 2014, 12:09 last edited by
        #3

        Oh, I didn't realize. I tried it and it seems to work! Thanks!

        1 Reply Last reply
        0

        1/3

        14 May 2014, 09:39

        • Login

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