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 get the string length in QML?
Forum Updated to NodeBB v4.3 + New Features

How to get the string length in QML?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 2 Posters 5.6k 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.
  • M Offline
    M Offline
    mirro
    wrote on last edited by
    #1
    TypeError: property 'length' of object is not a function
    
    QUrl source(“qrc:/qmlTest.qml”);
    QQuickWidget*  quickWidget = new QQuickWidget;
    quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView );
    quickWidget->setSource(source);
     
     
    import QtQuick 2.8
    import QtQuick.Controls 2.1
      
    Rectangle {
         id: mapWindow
         property string  date: ""
         Text{
                 x:0
                 y:0
                 font.family:"微软雅黑"
                 font.pointSize:7
                 text:date.substring(0,date.length())
                 color:"#0AAAB1"
         }
     }
    
    jsulmJ 1 Reply Last reply
    0
    • M mirro
      TypeError: property 'length' of object is not a function
      
      QUrl source(“qrc:/qmlTest.qml”);
      QQuickWidget*  quickWidget = new QQuickWidget;
      quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView );
      quickWidget->setSource(source);
       
       
      import QtQuick 2.8
      import QtQuick.Controls 2.1
        
      Rectangle {
           id: mapWindow
           property string  date: ""
           Text{
                   x:0
                   y:0
                   font.family:"微软雅黑"
                   font.pointSize:7
                   text:date.substring(0,date.length())
                   color:"#0AAAB1"
           }
       }
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @mirro Since length is a property shouldn't you remove ()?

      date.length
      

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2

      • Login

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