Reputation: 335
Is there any way to open a Qt process and then programatically add widgets? For example, start a process that opens a frame and then, with another call from, say, another program (that is mine; actually another scripting language), add a button to that frame?
So, in another program, I say "open frame" at the prompt and the frame opens. And then I say "add button" and the frame just opened is populated with a button.
Updated to address comment. Updated to add example.
Upvotes: 2
Views: 1164
Reputation: 46479
As already stated, it is possible. If you need a domain specific scripting language, I'd recommend using the QtScript module. It's based on ECMAScript 262 and allows access to signals, slots, and other things.
Although you could use IPC or TCP for controlling the application, Qxt provides QxtRPCPeer
that can be used to connect signals and slots between applications connected via a QIODevice, such as a TCP or local connection.
Upvotes: 1
Reputation: 20881
The easiest way would be to expose a set of functions from the main program (the one that draws) and load them from the "client" and simply call them when you need to.
Another approach that requires more work would be to use some sort of inter-process communication (such as shared memory, sockets, d-bus etc. for implementations you can either use the ones that Qt offers or boost):
A simplified example using sockets would be to have the main program listen on a socket waiting for commands and invoking the right function for each command. While the other program communicating with it upon receiving commands from the prompt.
Upvotes: 0
Reputation: 96109
If you can make the other app a dll/shared library that is loaded by the main app.
Then simply have a method draw menu or draw frame in the dll. The main app checks if the dll is present and loads it, it can then check if the gui method exists - this is the common way to implement gui plugins.
Upvotes: 0
Reputation: 9814
The best way to start doing this would using QSharedMemory to access the same memory in both processes and then what you describe should be perfectly possible.
Upvotes: 0
Reputation: 385970
That functionality is not built-in to Qt applications (or any window other fraemwork AFAIK), but you can build it in yourself if you are creating both programs.
Upvotes: 0