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. Convert text to uppercase
Forum Updated to NodeBB v4.3 + New Features

Convert text to uppercase

Scheduled Pinned Locked Moved Solved QML and Qt Quick
qml
3 Posts 2 Posters 6.4k Views
  • 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.
  • G Offline
    G Offline
    GrahamLa
    wrote on last edited by aha_1980
    #1

    Hi
    I have a qml item defined as

    import QtQuick 2.0
    import QtQuick.Controls 2.3
    import "../../Customisation"
    
    Item {
        id: systemControlApp
        Label {
            id: label
            x: 241
            y: 168
            width: 320
            height: 110
            text: Qt.binding(function() { return Style.systemControl.appLabel })
            font.pointSize: 25
        }
    
    }
    

    The Style.qml

    QtObject {
    
        property QtObject systemControl: QtObject {
            property string appLabel: "System Control"
            property color color: "#B7B865"
            property string imagePath: "/images/Section_SystemControl.svg"
        }
    }
    

    What I was hoping to achieve was to set the text in the item to value of the appLabel in Style BUT in Uppercase.

    As it stands I get this error

    Unable to assign a function to a property of any type other than var.
    

    Any ideas on how to implement this?

    Thanks

    GrecKoG 1 Reply Last reply
    0
    • G GrahamLa

      Hi
      I have a qml item defined as

      import QtQuick 2.0
      import QtQuick.Controls 2.3
      import "../../Customisation"
      
      Item {
          id: systemControlApp
          Label {
              id: label
              x: 241
              y: 168
              width: 320
              height: 110
              text: Qt.binding(function() { return Style.systemControl.appLabel })
              font.pointSize: 25
          }
      
      }
      

      The Style.qml

      QtObject {
      
          property QtObject systemControl: QtObject {
              property string appLabel: "System Control"
              property color color: "#B7B865"
              property string imagePath: "/images/Section_SystemControl.svg"
          }
      }
      

      What I was hoping to achieve was to set the text in the item to value of the appLabel in Style BUT in Uppercase.

      As it stands I get this error

      Unable to assign a function to a property of any type other than var.
      

      Any ideas on how to implement this?

      Thanks

      GrecKoG Offline
      GrecKoG Offline
      GrecKo
      Qt Champions 2018
      wrote on last edited by
      #2

      You could do:

      text: Style.systemControl.appLabel.toUpperCase() // (Qt.binding is not need for declarative assignment)
      

      or even:

      text: Style.systemControl.appLabel
      font.capitalization: Font.AllUppercase
      
      1 Reply Last reply
      4
      • G Offline
        G Offline
        GrahamLa
        wrote on last edited by
        #3

        Hi Thanks
        I did try these without success - but it seems that it was not working for a seemingly unrelated error.

        Thanks for your help

        1 Reply Last reply
        0

        • Login

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