c++ - Adding a Qt GUI to a Dynamic Library -


Greeting overflow I am trying to add a GUI to the current project. More specifically for a plugin that is loaded as a .so file (or when compiled at win32 a .dll )

Its threading of this project is already implemented to deal with portability I know that QT has its own cross-platform threading model, but it would be better to stay inside the existing threading model.

My question is for Qt veterans [I have just started reading docs]: Is it possible to embed GUI using Qt in the above mentioned plugin? The plugin is already a command line interface and I would like to make a GUI alternative, even if it has been compiled. Because those standard functions are called by the main program, the GUI (which I think will remain in the second thread) has to be made accessible or able to be called on so that the CLI thread can stay together and the standard functions Can work with any permutation of two interfaces.

Editing 1:

After playing with the code, I'm able to launch a simple GUI from the plugin. The plugin is already CLI and it has the work asked by the main program. I created a new bag on the initialization of the plugin and launched a blocked GUI from there:

  QApplication app (zero, zero); Window = new gggie; Window & gt; Show (); App.exec ();  

Here's the question: Is it possible to communicate with the GUI elements from the CPU thread or from the CLI thread?

Editing 2: Some results

Okay, there is no problem by starting a blocked GUI in a different thread. I'm also able to use widgets in the GUI from the main plugin thread. I understand that this practice has not only been discouraged by the answers given to me yet, but QT Libs is excluding certain warnings about unsafe access to another thread.

So far, I only work in Linux environment, maybe actual issues will be presented on other issues. I have seen only one mess which I can not say definitely related to:

After changing the maximum and minimum values ​​of a progress bar widget, the progress bar appears to be empty; Improvement was able to apply

  // Here I am setting the values ​​of Window-> Progress- Bar-> setMaximum (character.maxHP); Window & gt; ProgressBar_2- & gt; SetMaximum (character.maxMP); Window & gt; ProgressBar-> SetValue (character.curHP); Window & gt; ProgressBar_2- & gt; SetValue (character.curMP); // and right here window-> Progression-> Set isabel (wrong); Window & gt; ProgressBar-> SetVisible (true); Window & gt; ProgressBar_2- & gt; SetVisible (wrong); Window & gt; ProgressBar_2- & gt; SetVisible (true);  

I think my last question is, 'There is a particular situation where the QT GUIs reach from another thread are insecure and why?'

You can use a QT GUI from DLL, which is called from a non-Qt application. , But it can not be from a secondary thread, run in the main thread and the application is launched through the method of blocking the event loop, which gives the GUI to stop, so if you need to run the argument in your app That is independent of the GUI, then the argument is Will walk in a secondary thread.

If you feel ambitious, you can modify QoRoUpplications and Qientlop classes in such a way that you can manage event loop from your calling application, and it is probably not difficult at all. But as far as I know there is no way to do this with Qt from the box.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -