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 can I insert a function in a switch case?
QtWS25 Last Chance

How can I insert a function in a switch case?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
switchfunctionconnectsignalalias
1 Posts 1 Posters 525 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
    Mateus
    wrote on 26 Nov 2022, 13:38 last edited by
    #1

    I have a signal in my backend file (main.py) to send random values in variable "temped":

    temped = randint(35,40)
    [...]
    setTempED = Signal(str)
    [...]
    self.setTempED.emit(str(temped))

    And I have a .qml file with:

    property real temped
    
        Connections {
            target: backend
    
            function onSetTempED(temp2) {
               temped = temp2
            }
        }
    

    (In this variable, I receive the random value of setTempED)

    [...]

        Component.onCompleted: {
        selectparameter_Q1.okclicked1.connect(function(id){
    
            switch(id) {
    
            case 0:
                    monitorscreen.tq1.text = "Temp Óleo Freio (ED)"
                monitorscreen.q1.text = temped
                monitorscreen.q5.text = "°C"
                break
                [...]
    

    The signal "okclicked1(var id)" is in another .QML file, and It sends a signal to insert this value in an alias property

    My problem is, when I send the signal okclicked(), the field monitorscreen.q1.text receives the actual value of function, but doesn't update in real time, it stays fixed. I need that this variable been dynamic according to values generate by function.

    Here's a video to ilustrate the problem: https://drive.google.com/file/d/1iN6sSbb1Vy2N1TQg9aIurFLUhaJdE4iv/view?usp=sharing

    1 Reply Last reply
    0

    1/1

    26 Nov 2022, 13:38

    • Login

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