Either use asynchronous operations if available, or do the long tasks using threads. QtConcurrent can help you in some aspects here.
Either use asynchronous operations if available, or do the long tasks using threads. QtConcurrent can help you in some aspects here.
Hi,
If I have in the constructor Fn1, Fn2 and Fn3 which are call lineary (first goes Fn1, then Fn2 and so on, but never at the same time) then how and where should I make the threads?
QThread *mythread = new QThread;
and now? and where do you put it? I have never work before with threads -.-''
Last edited by roseicollis; 22nd December 2014 at 10:24.
Since you have fixed sequence of functions, dervice from QThread and implement that sequence in its run() method.
Then create an instance of that class and run it.
You could also create a second, non-UI program and start that from the UI program using QProcess.
Cheers,
_
Hi,
Ok so you mean to do :
Qt Code:
{ Q_OBJECT ... }To copy to clipboard, switch view to plain text mode
Then it says In member function 'virtual const QMetaObject* MainWindow::metaObject() const':/home/sg/Docs/.../moc_mainwindow.cpp:62: error: 'QObject' is an ambiguous base of 'MainWindow'
Ok here I'm completly lost ^^'' can you explain that better please?You could also create a second, non-UI program and start that from the UI program using QProcess.
Thanks,
You can only derive from one QObject based class.
QProcess is a Qt class that allows you to run other programs/executables.
So one parallel processing approach is to have a task program that can be blocking/sequential and have the main program run it via QProcess.
Cheers,
_
Then? How can I derive from both?
Do you mean that I have to make 2 projects and then unify them with a process?? If yes can you put the code or the idea more or less of it? I can't understand how can the code be.
Sorry for all, I'm really newbie with Qt and developing with threads/process/etc. I've been looking for some written examples to try to understand it more but can't find any for that, so could you please write it?
Thank you!
Didn't I just write that this is not possible?
How does asking how to do it make any sense?
Obviously there is no "how".
That is an option.
You can also have a project that contains two exectuables.
The template for a multi target project is called "subdirs".
The idea is two have two programs:
1) a GUI that needs to be event driven to stay responive
2) a simple non-GUI worker program that can block until it is done
Then have the GUI program run the non-GUI program using QProcess.
Multi-Process is an alternative to multithreading with slightly different properties.
Depends a lot on what that parallel task is, how much it needs to share data with the UI and how often it needs to communicate.
Cheers,
_
Bookmarks