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] Problem with properties when importing QtQuick.Controls 1.1
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Problem with properties when importing QtQuick.Controls 1.1

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 1.1k 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
    dualfaces
    wrote on 6 Feb 2014, 08:07 last edited by
    #1

    Hello all,

    i have a problem with a Button component and properties when I import QtQuick.Controls 1.1 .
    This is my Button.qml
    @
    import QtQuick 2.0

    Rectangle{
    property color buttonColor: "white"
    border.color: "black"
    border.width: 2
    property string buttonText: "default"
    Text{
    id: buttonLabel
    text: buttonText
    anchors.centerIn: parent;
    anchors.verticalCenterOffset: -1
    }

    signal buttonClick()
    onButtonClick: {
        console.log(buttonLabel.text + " clicked" )
    }
    
    MouseArea{
        id: buttonMouseArea
    
        anchors.fill: parent //anchor all sides of the mouse area to the rectangle's anchors
        //onClicked handles valid mouse button clicks
        onClicked: buttonClick()
    }
    
    color: buttonMouseArea.pressed ? Qt.darker(buttonColor, 1.5) : buttonColor
    

    }
    @

    And this is the snippet where i use it
    @
    Rectangle {
    id: outerBox
    color: "green"
    width: 0.9 * parent.width
    height: 0.2 * parent.height
    anchors.bottom: parent.bottom
    anchors.left: parent.left
    anchors.horizontalCenter: parent.horizontalCenter

        Button {
            id: testButton
            width: 0.1 * parent.width
            height: width
            anchors.right: parent.right
            anchors.bottom: parent.bottom
            anchors.rightMargin: 0.05 * parent.width
            anchors.bottomMargin: anchors.rightMargin
            text: "Test"
            buttonText: "Test"
            //onButtonClick:
    
        }
    
    }
    

    @

    Above this snippet there is another rectangle which has a slider, therefore I have the following imports:
    @
    import QtQuick 2.0
    import QtQuick.Controls 1.1
    @

    As soon as is import QtQuickControls it complains that there is no property buttonText and i cant assign a onButtonClick.
    What is conflicting? The text property sets a labeling of the button, but why isn't buttonText working?

    Thank you.

    Regards

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 6 Feb 2014, 08:34 last edited by
      #2

      I suspect you have a conflict right there: a Button element exists in QtQuick controls already. "Link":http://qt-project.org/doc/qt-5.1/qtquickcontrols/qml-qtquick-controls1-button.html. Either rename your button or maybe import is with an alias (not sure if that works for QML files).

      (Z(:^

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dualfaces
        wrote on 6 Feb 2014, 08:57 last edited by
        #3

        Thank you!
        That was quite easy. Renaming solved the problem.

        1 Reply Last reply
        0

        1/3

        6 Feb 2014, 08:07

        • 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