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. how to pass a variable from a one thread to main GUI thread

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 412 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      4

      • Login

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