Dialog QML issue



  • Hi,

    i press a button and then a dialog will open.
    Inside the dialog i am using a property string variable connected to a Q_OBJECT on c++.
    I handle the variable change inside the dialog and do some string compair.

    This is working fine but if i close the dialog and re-open it, the variable is never changed even if, on c++ side, i QEMIT a signal.

    So here is my QML dialog code:

    Dialog
    {
        id: messageDialog
        height: 300
        width: 500
        visible: false
    
        property string message_from_UART:SerialPort.message_UART
    
        onMessage_from_UARTChanged:
        {
             if(message_from_UART === "Offset Fehlgeschlagen Links")
             {
                 offset_links.color="red";
             }
             else if(message_from_UART === "Offset Erfolgreich Links")
             {
                 offset_links.color="green";
             }
             else if(message_from_UART === "PWDN")
             {
                 offset_links.color="grey";
                 offset_rechts.color="grey";
                 kalibrierung_rechts.color="grey";
                 kalibrierung_links.color="grey";
             }
             else if(message_from_UART === "Offset Fehlgeschlagen Rechts")
             {
                 offset_rechts.color="red";
             }
             else if(message_from_UART === "Offset Erfolgreich Rechts")
             {
                 offset_rechts.color="green";
             }
             else if(message_from_UART === "Kalibrierung fehlgeschlagen Rechts")
             {
                 kalibrierung_rechts.color="red";
             }
             else if(message_from_UART === "Kalibrierung erfolgreich abgeschlossen Rechts")
             {
                 kalibrierung_rechts.color="green";
             }
             else if(message_from_UART === "Kalibrierung fehlgeschlagen Links")
             {
                 kalibrierung_links.color="red";
             }
             else if(message_from_UART === "Kalibrierung erfolgreich abgeschlossen Links")
             {
                 kalibrierung_links.color="green";
             }
             else if(message_from_UART==="Sensor Problem oder Sensor nicht angeschlossen")
             {
                 spinner.visible=false;
                 errormessage.visible=true;
                 value_start_button=0;
                 SerialPort.write_UART("PWDN:");
                 image.source= "Start_schwarz.png";
                 start.text= "Start";
             }
        }
    

    this property "property string message_from_UART:SerialPort.message_UART" reads the QEMIT value from c++
    I declaire the c++ Q_OBJECT like this:

    Q_OBJECT
    Q_PROPERTY(QString message_UART READ message WRITE message_write NOTIFY messageChanged)

    I did the same test, open the dialog -> receive a signal -> compair the string ->close the dialog->open dialog->send a different string and emit signal-> signal dont get handle in "onMessage_from_UARTChange"

    Any idea?

    Edited: Please surround the code with ``` - p3c0


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.