Page 3 of 8 FirstFirst 12345 ... LastLast
Results 41 to 60 of 154

Thread: How to use separate threads for pushbuttons in QT (like SwingWorker in Java)

  1. #41
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to use separate threads for pushbuttons in QT (like SwingWorker in Java)

    No.

    Cheers,
    _

  2. #42
    Join Date
    Mar 2015
    Posts
    125
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: How to use separate threads for pushbuttons in QT (like SwingWorker in Java)

    Qt Code:
    1. QString p="C:\\C";
    2. QObject::connect(indexate, SIGNAL(clicked()),&f,SLOT (walk(p)));
    To copy to clipboard, switch view to plain text mode 
    It is simple solution, and the red wavy underline disappear even before compilation (is inactive again).
    Last edited by artt; 19th December 2015 at 01:01.

  3. #43
    Join Date
    Mar 2015
    Posts
    125
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: How to use separate threads for pushbuttons in QT (like SwingWorker in Java)

    d_trans I do not understand do you think I am right in connect statement as I cannot to check as I need to manipulate Qtcreator to make build and debug available.
    But i have similar situation yet about putting this connect statement in single thread:
    Here is my solution but I have two issues: the first is how to define the run() of Qthread as a slot?
    Here is my approach:
    Qt Code:
    1. I create Thread.h for several thread headers: here is for the first one for indexate button and walk() method.
    2. #ifndef ITHREAD_H
    3. #define ITHREAD_H
    4. #include <QWidget>
    5. #include "Filewalker.h"
    6. #include "Lister.h"
    7. class IThread : public QThread
    8. {
    9. Q_OBJECT
    10. public slots:
    11. void run();
    12. };
    13. #endif
    14. Then define run() in Lister.cpp without defining IThread constructor.
    15. void IThread::run()
    16. {
    17. Lister::walk(QString);
    18. }
    19. Maybe I should define run in new .cpp as walk() is also defined here.
    20. Then in main () I initialize
    21. Ithread variable, and start it. But to put it in connect I found just one wayout to assign ITread.start() to QObject instance by analogy to Java.
    22. IThread A;
    23. QObject pp=A.start();
    24. QObject::connect(indexate, SIGNAL(clicked()),&f,SLOT (pp)); //It is underlined in red from the left of line that probably is not //correct as well as two previous lines. As Ithread::run() in another file despite the red line appera even I click by mouse any new line before any insertion in Lister.cpp
    To copy to clipboard, switch view to plain text mode 
    Again I cannot check as I have no time to correct Qtcreator(and everytime), but I see it just in this way, especially starting Ithread???
    Last edited by artt; 19th December 2015 at 02:07.

  4. #44
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to use separate threads for pushbuttons in QT (like SwingWorker in Java)

    It is simple solution
    AND STILL INCORRECT

    The SIGNAL() and SLOT() macros each take as arguments the signature of the methods they will invoke, with the return type always being implicitly understood to be "void".

    Examples of correct SIGNAL() or SLOT() syntax are:

    Qt Code:
    1. SIGNAL( myMethod1() ) // a method that takes no parameters and returns void.
    2. SIGNAL( myMethod2( int ) ) // a method that takes an int parameter type
    3. SIGNAL( myMethod3( int, const QString & ) ) // a method that takes two parameters, one an int, the second a const QString reference
    To copy to clipboard, switch view to plain text mode 

    Examples of incorrect syntax are:

    Qt Code:
    1. SIGNAL( myMethod2( myVariable ) ) // "myVariable" is the name of a variable, not a type
    2. SIGNAL( myMethod3( 4, "some string" ) ) // "4" and "some string" are literals, not types
    To copy to clipboard, switch view to plain text mode 

    (Other examples of incorrect syntax include every "solution" you have posted).

    Furthermore, you cannot connect a signal with fewer parameters to a slot with more parameters unless the slot's parameters have default values. You cannot connect a signal to a slot with different parameter types. You can connect a signal with more parameters to a slot with fewer parameters; the extra parameters from the signal will be ignored.

    Qt Code:
    1. connect( myInstance1, SIGNAL( myMethod1() ), myInstance2, SLOT( myMethod2( int ) ) ) // error - no match for int slot parameter
    2. connect( myInstance1, SIGNAL( myMethod1( int ) ), myInstance2, SLOT( myMethod2() ) ) // OK; int signal parameter is ignored
    3. connect( myInstance1, SIGNAL( myMethod1( int, const QString & ) ), myInstance2, SLOT( myMethod2( int, double ) ) ) // error - parameter types don't match
    To copy to clipboard, switch view to plain text mode 

    QObject::connect(indexate, SIGNAL(clicked()),&f,SLOT (pp));
    Wrong - see example #1 of incorrect syntax above. "pp" is not a type, it is the name of a variable. And also wrong because the signal clicked() has no parameters. And wrong one more time because "pp" is not the signature of a slot defined in the class reference by the receiver "&f".
    Last edited by d_stranz; 19th December 2015 at 04:40.

  5. #45
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to use separate threads for pushbuttons in QT (like SwingWorker in Java)

    Quote Originally Posted by artt View Post
    Here is my solution but I have two issues: the first is how to define the run() of Qthread as a slot?
    And why would you want run() as a slot?
    You know that is the method that is executed by the worker thread, right? Just like in Java.

    Quote Originally Posted by artt View Post
    IThread A;
    QObject pp=A.start();
    That won't compile because QThrad::start() doesn't return anything.
    You know, just like in Java.

    It starts the thread which will then execute the run() method.
    You know, just like in Java.

    Cheers,
    _

  6. #46
    Join Date
    Mar 2015
    Posts
    125
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: How to use separate threads for pushbuttons in QT (like SwingWorker in Java)

    Should I make start() as a slot? Or to be correctly: Should I made some thirdlevel Wrapper method for walk as slot? That is place Lister::walk() in run(), then A.start(), and them Someclass(Lister also f.e.)::walkwiththread() as slot, where I would put A.start()?// should I use event in my thread to correctly interact with Mainthread? Some kind of post...()?

  7. #47
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to use separate threads for pushbuttons in QT (like SwingWorker in Java)

    Quote Originally Posted by artt View Post
    Should I make start() as a slot?
    QThread::start() is a slot.

    Quote Originally Posted by artt View Post
    Or to be correctly: Should I made some thirdlevel Wrapper method for walk as slot? That is place Lister::walk() in run(), then A.start(), and them Someclass(Lister also f.e.)::walkwiththread() as slot, where I would put A.start()?// should I use event in my thread to correctly interact with Mainthread? Some kind of post...()?
    I don't have a clue what you mean.

    But if you meant creating a slot that will call walk with an argument, then yes.

    Cheers,
    _

  8. #48
    Join Date
    Mar 2015
    Posts
    125
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: How to use separate threads for pushbuttons in QT (like SwingWorker in Java)

    I did not understand the first of your last statements? Is it some constatation(affirmation)? And I mean to make public slot: void Lister::walkwiththread() { A.start()}, when void IThread::run { Lister::walk(QString)}...
    /"Yes, that's a workable direction" -- is it not too much? Maybe there would be some cycle -- lister method --ithreadmethod--starting
    ithreadmethod--another lister method -- could it work? -- as I am really very tired of inactive Build-Debug menu
    Last edited by artt; 19th December 2015 at 18:32.

  9. #49
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to use separate threads for pushbuttons in QT (like SwingWorker in Java)

    Yes, that's a workable direction.

    Cheers,
    _

  10. #50
    Join Date
    Mar 2015
    Posts
    125
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: How to use separate threads for pushbuttons in QT (like SwingWorker in Java)

    If I define IThread::run() in Lister.cpp with definition of Lister::walk(QString path0), lower in the same file I got such errors with 2 modifications - should I define these 2 methods in different files or in inverse order?
    Qt Code:
    1. 1. void IThread::run()
    2. {
    3. static void Lister::walk(QString path0);
    4. }
    5.  
    6. ERRROR:invalid use of qualified-name 'Lister::walk'
    7.  
    8. 2.
    9. void IThread::run()
    10. {
    11. Lister::walk(QString);
    12. }
    13.  
    14. ERROR:expected primary-expression before ')' token
    To copy to clipboard, switch view to plain text mode 
    There is also run-time error with the argument of walk(pp) - so should I understand that I need just walk()?
    QString p="C:\\C";
    Object::connect: No such slot Lister::walk(pp) in ..\Filewalker2\main.cpp:32
    Last edited by artt; 20th December 2015 at 03:18.

  11. #51
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to use separate threads for pushbuttons in QT (like SwingWorker in Java)

    Quote Originally Posted by artt View Post
    Qt Code:
    1. 1. void IThread::run()
    2. {
    3. static void Lister::walk(QString path0);
    4. }
    5.  
    6. ERRROR:invalid use of qualified-name 'Lister::walk'
    7.  
    8. 2.
    9. void IThread::run()
    10. {
    11. Lister::walk(QString);
    12. }
    13.  
    14. ERROR:expected primary-expression before ')' token
    To copy to clipboard, switch view to plain text mode 
    The first one doesn't make sense. You want to call a function, not declare one.

    The second one is a function call, but you are passing a type as the argument instead of a value.
    Since that would not work in Java either I have now serious doubts that you have even programmed a single line in Java as well.

    Quote Originally Posted by artt View Post
    There is also run-time error with the argument of walk(pp) - so should I understand that I need just walk()?
    QString p="C:\\C";
    Object::connect: No such slot Lister::walk(pp) in ..\Filewalker2\main.cpp:32
    That has been already been answered several times.

    Cheers,
    _

  12. #52
    Join Date
    Mar 2015
    Posts
    125
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: How to use separate threads for pushbuttons in QT (like SwingWorker in Java)

    1. You provided such radical thoughts: it is very big blame to write I do not write a line in a Java
    despite it seems is thirdly light than Qt for such project. And of course there were attempts and errors.
    After providing arguments:
    QString path0="C:\\C";
    for Lister::walk(path0) it works (and after putting A->start() on the heap).
    But walkwiththread() works with small folders -- for example with 28 entities (shows the properties of 28 files) - but when with C:\Windows, it is inactive. And in debugger mode - when clicking on indexate() button for running walkwiththread()
    I got the instant message: "Thread 1 of Group 1 finished" (in one of status bar of Qtcreator tabs), then clicking the second time "Thread 2 of Group 1 finished", etc. So maybe I need some another wrapper or additional method for launching
    time-consuming thread - as 28 entities(or 19, or 5) renders instantly??
    Anyway in both cases when seeing Debugger launched in console - I see at first the familiar message about absence of 22 libraries--but it display after the list of results with small folders..
    And I put in .pro file: Qt+= gui core thread concurrent or ... threads concucrrent --despite I cannot found the reference about it in 2 my read books, but there is reference for "concurrent" in Blanchette despite it is another Qtconcurrent class.
    So partially such scheme works..
    And what about walk(pp) -- even in Auto-fill mode of Qtcreator I see SLOT(walk(QString)) - so the message in some kind the error - as such slot is present. Or should I to provide walk() without arguments or make clicked(pp) with arguments.
    Last edited by artt; 20th December 2015 at 16:41.

  13. #53
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to use separate threads for pushbuttons in QT (like SwingWorker in Java)

    Quote Originally Posted by artt View Post
    1. You provided such radical thoughts: it is very big blame to write I do not write a line in a Java
    Well, that was based on the failure to understand the difference between a type and a variable.
    Because Java has exactly the same terminology for these concepts.

    E.g.
    Qt Code:
    1. class Main
    2. {
    3. static void main(String[] args)
    4. {
    5. String pp;
    6. }
    7. };
    To copy to clipboard, switch view to plain text mode 
    String is a type, pp is a variable of type String. pp is not a type.
    In Java doing this would also not compile
    Qt Code:
    1. void walk(String path)
    2. {
    3. }
    4.  
    5. void doWalk()
    6. {
    7. walk(String);
    8. }
    To copy to clipboard, switch view to plain text mode 
    Again, because walk() expects an argument of type String, not the type itself.

    Since half of the thread deals with you not understanding these simple facts for C++, I could only conclude that you don't understand them in Java either.

    Quote Originally Posted by artt View Post
    but when with C:\Windows, it is inactive.
    What does that even mean "inactive"?
    Does the method not execute depending on what you pass as its argument?

    Quote Originally Posted by artt View Post
    And I put in .pro file: Qt+= gui core thread concurrent
    I am pretty sure "thread" is not a name for a Qt module.
    "gui", "core" and "concurrent" are, the latter being needed for use of QtConcurrent, not for QThread.
    QThread is part of QtCore.

    Quote Originally Posted by artt View Post
    or ... threads concucrrent --despite I cannot found the reference about it in 2 my read books, but there is reference for "concurrent" in Blanchette despite it is another Qtconcurrent class.
    QtConcurrent is a namespace for functions that primarily deal with parallel algorithms, such as invoking the same function on all elements in a container, for multiple container entries concurrently.

    Quote Originally Posted by artt View Post
    And what about walk(pp) -- even in Auto-fill mode of Qtcreator I see SLOT(walk(QString))
    So far your code indicated that pp was a variable of type QString, not a type called pp.
    Do you have a class called "pp"?
    Is the slot taking an argument of type "pp"?

    Cheers,
    _

  14. #54
    Join Date
    Mar 2015
    Posts
    125
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: How to use separate threads for pushbuttons in QT (like SwingWorker in Java)

    Of course, QString pp="C:\\C" means that pp is variable of Qstring. But I cannot put simply SLOT(walk(Qstring)), as the folder would not be defined so I put there concrete variable pp. Oh, in the course of writing these comment, I guessed maybe I need
    to put Lister::walk(QString) as Lister::walk(pp), or even put pp("C:\\C") as a argument in declaration of slot public Lister { slot: walk(QString pp). } So it happened to be some euristics. In some way it should works.
    Anyway - in thread environment this issue should be absent- but QThread do not work with processing big folder - taht is issue now. So I do undestand I need some tool for time-consuming for time-sonsuming thread.

  15. #55
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to use separate threads for pushbuttons in QT (like SwingWorker in Java)

    Quote Originally Posted by artt View Post
    Of course, QString pp="C:\\C" means that pp is variable of Qstring.
    Good that we could clarify that.

    Quote Originally Posted by artt View Post
    But I cannot put simply SLOT(walk(Qstring)), as the folder would not be defined so I put there concrete variable pp.
    Explained several times already.

    Quote Originally Posted by artt View Post
    Anyway - in thread environment this issue should be absent- but QThread do not work with processing big folder - taht is issue now.
    A thread is just a parallel execution context.
    It doesn't matter to the thread how big a folder is.

    Quote Originally Posted by artt View Post
    So I do undestand I need some tool for time-consuming for time-sonsuming thread.
    No idea what you mean.

    Cheers,
    _

  16. #56
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to use separate threads for pushbuttons in QT (like SwingWorker in Java)

    doublefacepalm.jpg

    I'm beaming out of here.

  17. #57
    Join Date
    Mar 2015
    Posts
    125
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: How to use separate threads for pushbuttons in QT (like SwingWorker in Java)

    I do not really understand you facepalm, and suspects of java code-- the only I copied from the net was exactly filewalker pattern (yet in qt).
    Anyway eveything almost works
    -- "is inactive" -- when I press indexate button and walkerwiththread() process C:\\Document and Settings (wriitten directly in Lister.cpp)-- i got nothing in console.
    If it processes C:\\C (wriitten directly in Lister.cpp) it instantly render 28 results for other folder.
    Maybe not everything is on heap, and yet in stack as it was at the beginning?
    Anyway in both cases -- when Debug started...
    I got such lines in console:
    Could not load shared library symbols for 22 libraries, e.g. C:\WINDOWS\system32\ntdll.dll.
    Use the "info sharedlibrary" command to see the complete listing.
    So it happened when my Qfilelistinfo was on the stack.
    Then small folders shows:
    Qt Code:
    1. File:1656 catalog.php C:/includes/admin 4
    2. File:1735 conf.php C:/includes/admin 4
    3. File:1590 custord.php C:/includes/admin 4
    4. File:4256 catalog_products_categories.php C:/includes/admin/sub 4
    5. File:2754 catalog_special.php C:/includes/admin/sub 4
    To copy to clipboard, switch view to plain text mode 
    ... (Big Folders nothing).
    If I click again thread(it shows the thread2, and so on)
    I got again
    File:1656 catalog.php C:/includes/admin 4
    File:1735 conf.php C:/includes/admin 4...
    So this "Could not load shared library" appears at the beginning of run, so creation of Qwidget.
    Really a very small need sto be done -- and it is really needs some SwingWorker java analogue as it renders instantly, but
    in case of C:\Windows it could noty happened as well in the case of whole C:\, or all disks..

  18. #58
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to use separate threads for pushbuttons in QT (like SwingWorker in Java)

    Quote Originally Posted by artt View Post
    -- "is inactive" -- when I press indexate button and walkerwiththread() process C:\\Document and Settings (wriitten directly in Lister.cpp)-- i got nothing in console.
    If it processes C:\\C (wriitten directly in Lister.cpp) it instantly render 28 results for other folder.
    And you have equal access rights to both folders?

    Have you added addition logging to see what happens?

    Quote Originally Posted by artt View Post
    Maybe not everything is on heap, and yet in stack as it was at the beginning?
    We've already determined that this doesn't matter.

    Quote Originally Posted by artt View Post
    Anyway in both cases -- when Debug started...
    I got such lines in console:
    Could not load shared library symbols for 22 libraries, e.g. C:\WINDOWS\system32\ntdll.dll.
    Use the "info sharedlibrary" command to see the complete listing.
    Obviously the debugger can't find the debug symbols for these libraries.
    Not a problem until you have to debug into them.

    Quote Originally Posted by artt View Post
    Really a very small need sto be done -- and it is really needs some SwingWorker java analogue as it renders instantly
    So it works when you run everything from the main thread?

    Cheers,
    _

  19. #59
    Join Date
    Mar 2015
    Posts
    125
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: How to use separate threads for pushbuttons in QT (like SwingWorker in Java)

    No once I put:
    Qt Code:
    1. QString path0="C:\\includes";
    2. void IThread::run()
    3. {
    4. Lister::walk(path0);
    5. } -- and run it. Then change to:
    6. QString path0="C:\\Windows";
    7. void IThread::run()
    8. {
    9. Lister::walk(path0);
    10. }
    To copy to clipboard, switch view to plain text mode 
    and run.
    Everything not works, unfortunately...
    Excerpts from Qt Assistant:
    In practice, the impossibility of using GUI classes in other threads than the main thread can easily be worked around by putting time-consuming operations in a separate worker thread and displaying the results on screen in the main thread when the worker thread is finished.
    Maybe I need some additional methods or tools to wait when worker thread made nessesary work, and then return in mainthread-- as I see that workerthread return immediately, it doesnt wait.
    I read 2-3 days ago about linking worker thread to main(GUI)thread and as I remember there were mentioned as events as the some method post..() but it is not 100% postevents(), although maybe. Anyway there are also option Qtconcurrent(), despite i am not aware is it applicable for several threads (buttons) along mainthread, and qRunnable.
    There is also Mandelbrot and the Blocking Fortune Client example in QtAssistant -despite it is too compicated for me as for now, and I do not need any blocking and mutex, just deblocking-that several buttons could be available in the same time-and main gui would not be non-freezing


    Added after 22 minutes:


    No once I put:
    Qt Code:
    1. QString path0="C:\\includes";
    2. void IThread::run()
    3. {
    4. Lister::walk(path0);
    5. } -- and run it. Then change to:
    6. QString path0="C:\\Windows";
    7. void IThread::run()
    8. {
    9. Lister::walk(path0);
    10. }
    To copy to clipboard, switch view to plain text mode 
    and run.
    Everything not works, unfortunately...
    Excerpts from Qt Assistant:
    In practice, the impossibility of using GUI classes in other threads than the main thread can easily be worked around by putting time-consuming operations in a separate worker thread and displaying the results on screen in the main thread when the worker thread is finished.
    Maybe I need some additional methods or tools to wait when worker thread made nessesary work, and then return in mainthread-- as I see that workerthread return immediately, it doesnt wait.
    I read 2-3 days ago about linking worker thread to main(GUI)thread and as I remember there were mentioned as events as the some method post..() but it is not 100% postevents(), although maybe. Anyway there are also option Qtconcurrent(), despite i am not aware is it applicable for several threads (buttons) along mainthread, and qRunnable.
    There is also Mandelbrot and the Blocking Fortune Client example in QtAssistant -despite it is too compicated for me as for now, and I do not need any blocking and mutex, just deblocking-that several buttons could be available in the same time-and main gui would not be non-freezing
    //Just now I put the folder to path0 variable with about rendered 1000 results, and 3-4 secs. of processing. So it is not instant.
    But it actually do not reacts for such meta-directories as C:\Windows, C:\Documenst and Settings or simply the C:\ -- that is fact. You should understand that I change the name of folders directly in the code, and for testing purposes
    Last edited by artt; 20th December 2015 at 23:12.

  20. #60
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to use separate threads for pushbuttons in QT (like SwingWorker in Java)

    Quote Originally Posted by artt View Post
    Everything not works, unfortunately...
    Let me repeat:

    Does it work when you have no additional thread?


    Quote Originally Posted by artt View Post
    In practice, the impossibility of using GUI classes in other threads than the main thread can easily be worked around by putting time-consuming operations in a separate worker thread and displaying the results on screen in the main thread when the worker thread is finished.
    Maybe I need some additional methods or tools to wait when worker thread made nessesary work, and then return in mainthread-- as I see that workerthread return immediately, it doesnt wait.
    If you mean QThread::start() returns immediately, then yes of course, that's the whole point.

    Quote Originally Posted by artt View Post
    I read 2-3 days ago about linking worker thread to main(GUI)thread and as I remember there were mentioned as events as the some method post..() but it is not 100% postevents(), although maybe.
    You can use events but using a signal is way easier.
    If the thread doesn't have to report progress, then connect to the thread's finished() signal.

    Anyway, make sure the program works without threads before making it more complex.

    Cheers,
    _

Similar Threads

  1. Replies: 1
    Last Post: 1st April 2014, 09:48
  2. Destruction in separate threads
    By KevinKnowles in forum Qt Programming
    Replies: 3
    Last Post: 19th March 2012, 10:49
  3. Problem with QProcess in two separate threads
    By viheaho in forum Qt Programming
    Replies: 2
    Last Post: 18th March 2010, 23:52
  4. Replies: 1
    Last Post: 7th December 2009, 08:26
  5. Calling same method from separate threads
    By steg90 in forum Qt Programming
    Replies: 2
    Last Post: 19th July 2007, 09:55

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.