Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Can't use int variable in button textbox
Forum Updated to NodeBB v4.3 + New Features

Can't use int variable in button textbox

Scheduled Pinned Locked Moved Solved Mobile and Embedded
3 Posts 2 Posters 301 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.
  • T Offline
    T Offline
    tEdward
    wrote on last edited by
    #1

    So, I'm trying to make an app in which if I push a button, the number on it will increase by one. I tried doing it by declaring a universal int variable(Num), and onClicked: Num++;. But I found no way to display that variable in text: ...
    I don't have the faintest idea how to do it.

    Any help would be appreciated!

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tEdward
      wrote on last edited by
      #2

      Thought I'd just post this as well

      Button {
              id: button
              x: 110
              y: 220
              width: 375
              height: 180
              text: 
              font.pointSize: 30
              scale: 0.4
              anchors.verticalCenter: parent.verticalCenter
              anchors.horizontalCenter: parent.horizontalCenter
              onClicked: Num++;
          }
      

      Also the button is from QtQuick - Controls 2.

      ODБOïO 1 Reply Last reply
      0
      • T tEdward

        Thought I'd just post this as well

        Button {
                id: button
                x: 110
                y: 220
                width: 375
                height: 180
                text: 
                font.pointSize: 30
                scale: 0.4
                anchors.verticalCenter: parent.verticalCenter
                anchors.horizontalCenter: parent.horizontalCenter
                onClicked: Num++;
            }
        

        Also the button is from QtQuick - Controls 2.

        ODБOïO Offline
        ODБOïO Offline
        ODБOï
        wrote on last edited by ODБOï
        #3

        @tEdward hi

        Window {
            width: 800
            height: 600
            visible: true
            
            property int num : 0
        
            Button {
                    id: button
                    text: num //<
                    onClicked: num++
                }
        }
        
        1 Reply Last reply
        3

        • Login

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