Results 1 to 7 of 7

Thread: Multi-threading

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2012
    Location
    Porto
    Posts
    38
    Thanks
    4
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Multi-threading

    In my mainwindow i have
    Qt Code:
    1. th = new QThread;
    2. qDebug()<< "ID->" << thread()->currentThreadId();
    3. worker= new Worker(&ClassHasSomethingToDo);
    4. worker->moveToThread(th);
    5. th->start();
    To copy to clipboard, switch view to plain text mode 

    So, as I have above I can get two threads running in simultaneous.

    Mainwindow has a button when is clicked, shows a dialog.

    This dialog has to communicate with the class(ClassHasSomethingToDo) passed the Worker.

    In dialog I have

    Qt Code:
    1. QInitTokenDialog(ClassHasSomethingToDo*todo, QWidget *parent)
    2. this->todo=todo;
    3. connect(todo, SIGNAL(message(QString)), ui->textEdit, SLOT(setText(QString)));
    4. QMetaObject::invokeMethod(todo, "getMessage", Qt::AutoConnection);
    To copy to clipboard, switch view to plain text mode 

    I cant catch the signal emitted by ClassHasSomethingToDo. Why guys?

    Thanks for all answers, and sorry my English :P

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Multi-threading

    How are we supposed to know that? Does your connect() statement return true or false? Do you get any warnings on the console while the program is running?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Qt Multi Threading RePainting Problem
    By Mohammad in forum Qt Programming
    Replies: 4
    Last Post: 12th January 2012, 15:52
  2. Slow Multi-Threading
    By AwDogsgo2Heaven in forum Qt Programming
    Replies: 5
    Last Post: 19th July 2009, 21:36
  3. Multi-threading
    By lixo1 in forum Qt Programming
    Replies: 5
    Last Post: 22nd June 2009, 13:22
  4. Multi threading ...
    By kiranraj in forum Qt Programming
    Replies: 2
    Last Post: 18th June 2007, 16:51
  5. Multi-threading
    By shamik in forum Qt Programming
    Replies: 15
    Last Post: 28th November 2006, 10:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.