Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Basic qml label update with cpp
Qt 6.12 LTS is out! See what's new in the release blog

Basic qml label update with cpp

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 851 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
    MaxBec
    wrote on last edited by
    #1

    Hey guys,

    i have a pretty simple question but i dont find a solution:

    I want to update this qml component when the property ACSQmlTool.linkTool.isConnected changes:

    Label {
    	id:                      connectionLost
    	text:		         ACSQmlTool.linkTool.isConnected ? qsTr("Link connected!") : qsTr("Link disconnected")
    	font.pointSize:		 ScreenTools.defaultFontPointSize
    	font.family:		 ScreenTools.normalFontFamily
    	font.weight:		 Font.Normal
    	color:			 ACSQmlTool.linkTool.isConnected ? ACSPalette.lightblueLight : ACSPalette.orange
    	visible:		 ACSQmlTool.linkTool.isConnected
    }
    

    Unfortunately it doesn't change even if the property changes.

    ODБOïO 1 Reply Last reply
    0
    • M MaxBec

      Hey guys,

      i have a pretty simple question but i dont find a solution:

      I want to update this qml component when the property ACSQmlTool.linkTool.isConnected changes:

      Label {
      	id:                      connectionLost
      	text:		         ACSQmlTool.linkTool.isConnected ? qsTr("Link connected!") : qsTr("Link disconnected")
      	font.pointSize:		 ScreenTools.defaultFontPointSize
      	font.family:		 ScreenTools.normalFontFamily
      	font.weight:		 Font.Normal
      	color:			 ACSQmlTool.linkTool.isConnected ? ACSPalette.lightblueLight : ACSPalette.orange
      	visible:		 ACSQmlTool.linkTool.isConnected
      }
      

      Unfortunately it doesn't change even if the property changes.

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

      @MaxBec hi
      what is that ACSQmlTool ? how it is exposed to qml ?

      @MaxBec said in Basic qml label update with cpp:

      even if the property changes.

      how do you check that ?

      1 Reply Last reply
      0
      • M Offline
        M Offline
        MaxBec
        wrote on last edited by
        #3

        LinkTool:

        class ACSLinkTool : public ACSAbstractTool
        {
        		Q_OBJECT
        
        	public:
        		ACSLinkTool(ACSApplication* app, ACSToolbox* toolbox);
        		~ACSLinkTool();
        
        		Q_PROPERTY(bool						isBluetoothAvailable		READ isBluetoothAvailable		CONSTANT)
        		Q_PROPERTY(ACSQmlListModel*				linkConfigurations			READ _qmlLinkConfigurations		NOTIFY linkConfigurationsChanged)
        		Q_PROPERTY(QStringList					linkTypeStrings			READ linkTypeStrings			CONSTANT)
        		Q_PROPERTY(QStringList					serialBaudRates			READ serialBaudRates			CONSTANT)
        		Q_PROPERTY(QStringList					serialPortStrings			READ serialPortStrings			NOTIFY commPortStringsChanged)
        		Q_PROPERTY(QStringList					serialPorts				READ serialPorts				NOTIFY commPortsChanged)
        		Q_PROPERTY(bool						isConnected				READ isConnected				NOTIFY isConnectedChanged)
        

        QmlTool:

        qmlRegisterSingletonType		<ACSQmlTool>				("ACSCpp.Qml",				1, 0, "ACSQmlTool",				qmlToolSingletonFactory);
        

        isConnected is directly changed in the code for debug purposes.

        ODБOïO 1 Reply Last reply
        0
        • M MaxBec

          LinkTool:

          class ACSLinkTool : public ACSAbstractTool
          {
          		Q_OBJECT
          
          	public:
          		ACSLinkTool(ACSApplication* app, ACSToolbox* toolbox);
          		~ACSLinkTool();
          
          		Q_PROPERTY(bool						isBluetoothAvailable		READ isBluetoothAvailable		CONSTANT)
          		Q_PROPERTY(ACSQmlListModel*				linkConfigurations			READ _qmlLinkConfigurations		NOTIFY linkConfigurationsChanged)
          		Q_PROPERTY(QStringList					linkTypeStrings			READ linkTypeStrings			CONSTANT)
          		Q_PROPERTY(QStringList					serialBaudRates			READ serialBaudRates			CONSTANT)
          		Q_PROPERTY(QStringList					serialPortStrings			READ serialPortStrings			NOTIFY commPortStringsChanged)
          		Q_PROPERTY(QStringList					serialPorts				READ serialPorts				NOTIFY commPortsChanged)
          		Q_PROPERTY(bool						isConnected				READ isConnected				NOTIFY isConnectedChanged)
          

          QmlTool:

          qmlRegisterSingletonType		<ACSQmlTool>				("ACSCpp.Qml",				1, 0, "ACSQmlTool",				qmlToolSingletonFactory);
          

          isConnected is directly changed in the code for debug purposes.

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

          @MaxBec said in Basic qml label update with cpp:

          did you emit isConnectedChanged() signal when you write the new value?

          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
          • Unsolved