[beginner] action type property



  • Hi,
    I'm really beginner, so maybe my question is stupid, but i cant google the answer.
    I want to define my own "windget" witch should have action typed property
    so in file SelField.qml i have

    @Item{
    id: selField

    property string labelText
    property string fieldText
    property string placeholderText
    property action btnAction
    

    ...
    @

    Now I trying to use it

    @ SelField {
    id: firmwareSelection
    btnAction: openFirmwareAction
    labelText: qsTr("Firmware file path:")
    placeholderText: qsTr("<Select file>")
    fieldText: firmwarePath
    }@

    But component could not be loaded
    "QQmlApplicationEngine failed to load component
    file:///C:/Users/kku/Documents/hobby/elektronika/my_projects/_qt/FirmwareUpdater/build-FirmwareUpdater-Desktop_Qt_5_1_1_MinGW_32bit-Debug/qml/FirmwareUpdater/MainView.qml:125 Type SelField unavailable
    file:///C:/Users/kku/Documents/hobby/elektronika/my_projects/_qt/FirmwareUpdater/build-FirmwareUpdater-Desktop_Qt_5_1_1_MinGW_32bit-Debug/qml/FirmwareUpdater/SelField.qml:11 Expected property type"

    When I remove
    @ Item{
    id: selField

    property string labelText
    property string fieldText
    property string placeholderText
    

    // property action btnAction
    @

    I can use selField without problems

    @ SelField {
    id: firmwareSelection
    //btnAction: openFirmwareAction
    labelText: qsTr("Firmware file path:")
    placeholderText: qsTr("<Select file>")
    fieldText: firmwarePath
    }@

    What do I wrong, I just want to assign this property to the button...
    @ Button {
    id: button1
    action: btnAction
    text: qsTr("...")
    anchors.right: parent.right
    anchors.rightMargin: 0
    width: 50
    }@

    Does only string type could be use in "property" statement?

    Thank you in advance
    Krzysiek


  • Moderators

    Here is the list: "link":http://qt-project.org/doc/qt-5.0/qtqml/qtqml-typesystem-basictypes.html. Be sure to check out the docs first, Qt has very good documentation.



  • Hi,
    Thanks for replay, I got it, but how about action type
    "link.":http://qt-project.org/doc/qt-4.8/qml-action.html
    Why it's not mentioned in list provided by you? It's also described as basic type.
    Does qt 5.0 is not compatible with 4.8 ?
    Thank you in advance
    Krzysiek

    PS
    another list containing action as basic type
    "link":http://qt-project.org/doc/qt-4.8/qdeclarativebasictypes.html


  • Moderators

    It is fully compatible ;) In Qt5 you can choose between QtQuick1 (sometimes called QtDeclarative) and QtQuick2 (found in QtQuick and QtQml modules). They are not source compatible, indeed.

    I've never used the action property, so I can't say what happened to it in QtQuick2. Try mimicking it with "var" type.



  • Hi,
    I just checked source cod of standard button, and similar property type is "Action" instead of "action" :)
    Now it works perfect....

    Regards
    Krzysiek


Log in to reply
 

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