how to pass a variable from a one thread to main GUI thread



  • I am using following code

    QVariant myclass::Execute(QString command, QString xInfo)
    {
    QTimer::singleShot(0, this, SLOT(slotExecuteTcl()));
    return QVariant(true);
    }
    void myClass::executeTcl()
    {
    QString res;
    if ( Tcl_Eval(command, res) ) {

    }
    

    // return QVariant(res);

    }

    I want to pass command from ::Execute to executeTcl , since we move from one thread to GUI main thread could you please suggest how to move the variable from one thread to GUI main thread


  • Qt Champions 2016

    Hi
    You can make a new signal

    signals:
    void MyValue( QString );

    and in execute, emit it
    void myClass::executeTcl()
    { ...
    emit MyValue("somestring"); // or via variable
    }

    You have to have
    some slot in main connected to MyValue signal.


Log in to reply
 

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