Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Dialog QML issue
Forum Updated to NodeBB v4.3 + New Features

Dialog QML issue

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 317 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.
  • michaelLM Offline
    michaelLM Offline
    michaelL
    wrote on last edited by p3c0
    #1

    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

    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