[solved] Derived Component?



  • 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?



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



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.