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. How to change the text of the label

How to change the text of the label

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 2 Posters 999 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.
  • M Offline
    M Offline
    Mikeeeeee
    wrote on last edited by
    #1

    Hi!
    How to change the text of the label?
    I get the error: page1Label2 is not defined
    Page1Form.ui.qml:

    import QtQuick 2.4
    import QtQuick.Controls 2.4
     
    Item {
        id: element
        width: 400
        height: 600
        property alias page1Button1: page1Button1
        property alias page1Button0: page1Button0
        property alias page1ButtonMenu: page1ButtonMenu
     
        Button {
            id: page1Button0
            x: 66
            y: 172
            width: 128
            height: 128
            //font.capitalization: Font.AllUppercase
            //display: AbstractButton.TextOnly
            //topPadding: 5
            Image {
                id: image
                width: 130
                height: 130
                anchors.topMargin: 0
                anchors.leftMargin: 0
                anchors.rightMargin: 0
                anchors.bottomMargin: 0
                anchors.fill: parent
                source: "qrc:/images/images/close.png"
                fillMode: Image.Stretch
            }
        }
     
        Button {
            id: page1Button1
            x: 251
            y: 172
            width: 130
            height: 130
            Image {
                id: image1
                width: 130
                height: 130
                anchors.rightMargin: 0
                anchors.bottomMargin: 0
                anchors.fill: parent
                source: "qrc:/images/images/close.png"
                fillMode: Image.Stretch
            }
        }
     
        Button {
            id: page1ButtonMenu
            x: 150
            y: 479
            text: qsTr("МЕНЮ")
            font.pointSize: 18
        }
     
        Label {
            id: page1labe0
            x: 57
            y: 47
            width: 286
            height: 33
            text: qsTr("Выберете красный цвет")
            horizontalAlignment: Text.AlignHCenter
            font.pixelSize: 22
            font.family: "Verdana"
            font.weight: Font.Thin
        }
     
        Label {
            id: page1Label1
            x: 122
            y: 340
            width: 156
            height: 56
            text: qsTr("Побед: 0%")
            font.pointSize: 20
            horizontalAlignment: Text.AlignHCenter
        }
     
        Label {
            id: page1Label2
            x: 122
            y: 409
            width: 156
            height: 56
            text: qsTr("1 из 20")
            horizontalAlignment: Text.AlignHCenter
            font.pointSize: 20
        }
        states: [
            State {
                name: "Page1State1"
     
                PropertyChanges {
                    target: image
                    source: "qrc:/images/images/red.png"
                }
     
                PropertyChanges {
                    target: image1
                    source: "qrc:/images/images/black.png"
                }
            },
            State {
                name: "Page1State2"
     
                PropertyChanges {
                    target: image
                    source: "qrc:/images/images/black.png"
                }
     
                PropertyChanges {
                    target: image1
                    source: "qrc:/images/images/red.png"
                }
            },
            State {
                name: "Page1State0"
            }
        ]
    }
    

    Page1.qml:

    import QtQuick 2.4
    import QtQml 2.12
     
    Page1Form {
     
        page1Button0.onClicked: //left button
        {  
            page1Label2.text = "weg"
        }
     
    }
    
    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      @Mikeeeeee said in How to change the text of the label:

      property alias page1ButtonMenu: page1ButtonMenu
      

      You probably need to add an alias for it, like you do for the buttons etc.

      Not sure, I'm not using that .ui.qml weirdness.

      (Z(:^

      1 Reply Last reply
      1

      • Login

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