Important: Please read the Qt Code of Conduct -

Basic qml label update with cpp

  • 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		 ScreenTools.normalFontFamily
    	font.weight:		 Font.Normal
    	color:			 ACSQmlTool.linkTool.isConnected ? ACSPalette.lightblueLight :
    	visible:		 ACSQmlTool.linkTool.isConnected

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

  • @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 ?

  • LinkTool:

    class ACSLinkTool : public ACSAbstractTool
    		ACSLinkTool(ACSApplication* app, ACSToolbox* toolbox);
    		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)


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

    isConnected is directly changed in the code for debug purposes.

  • @MaxBec said in Basic qml label update with cpp:

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

Log in to reply