Results 1 to 5 of 5

Thread: plugins with separate windows

  1. #1
    Join Date
    Mar 2008
    Posts
    44
    Thanks
    2
    Platforms
    Unix/X11 Windows

    Default plugins with separate windows

    Hello

    I have an SDR (Software Defined Radio) application that I want to extend. Basically the architecture of the program implementing the SDR is simple:
    I read data from some device, do some processing (set some parameters and show some things), and pass processed data on to a selected decoder.
    Currently I have app 10 decoders (typical decoders are for speech, usb, lsb, fm, rtty, psk, morse decoding, fax etc etc).
    The structure of the user interaction with each of the decoders is different, the
    input of the decoders is a simple stream, the output things written on a screen and a simple (data) stream. Each
    decoder has its own (sub)screen on which decoder-specific interaction takes place, and a few,
    very limited, connection to the main program. The subscreens are implemented as a stacked construct.
    Since the number of decoders is growing, a few more are under development, I was thinking on a different, more dynamic, structure,
    one were decoders are loaded dynamically, and off-loaded when another one is requested for. Then at the start of the program a list is made of
    available decoders, such that a selector can be made. In such a set up, a user could even decide only to have a subset of the decoders on his machine, while
    on the other hand, the program could be extended without recompilation: adding a new decoder somewhere
    would cause it to be available on the next program start.

    I was thinking whether the plug-in features of Qt could be helpful or otherwise it better could be solved by having the
    decoders as separate programs, connected to the "main program" through a relatively simple IP mechanism. The biggest problem
    with the plugin approach to me seems to be the dynamic creation (and destruction) of interaction windows (either
    separate or embedded in the programs main window), something I really have no idea about (currently I am a simple user
    of the Qt designer to create the GUI).

    Any idea on this issue would be greatly appreciated.

    thanks in advance
    jan

  2. #2
    Join Date
    Dec 2012
    Posts
    90
    Thanks
    5
    Thanked 20 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: plugins with separate windows

    Quote Originally Posted by janK View Post
    The biggest problem
    with the plugin approach to me seems to be the dynamic creation (and destruction) of interaction windows (either
    separate or embedded in the programs main window), something I really have no idea about (currently I am a simple user
    of the Qt designer to create the GUI).
    That's really easy You see, to create window(or widget) you simple call it's constructor and then add resulting window to the respective layout/widget. You always can see generated Ui files for a simple example, or feel free to ask.
    For example you can setup your plugin/main window somehow about this way:
    Qt Code:
    1. class MainWindow {
    2. public:
    3. void loadPlugin () {
    4. PluginInterface *loadedPlugin = doLoad ();
    5. QWidget pluginWindow = loadedPlugin->createPluginWindow ();
    6. pluginWindow->setParent(this);
    7. this->ui->centralLayout->addWidget (pluginWindow);
    8. };
    9. };
    10.  
    11. class PluginInterface {
    12. public:
    13. QWidget * createPluginWindow () {
    14. return new MyPluginWindow;
    15. };
    16. };
    To copy to clipboard, switch view to plain text mode 

    On details of how to create and load plugin look at the plug&paint example here:
    http://qt-project.org/doc/qt-4.8/too...gandpaint.html

  3. #3
    Join Date
    Nov 2009
    Posts
    39
    Thanks
    9
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: plugins with separate windows

    janK,

    Just wanted to offer a (perhaps irrelavent) tip that caused a me lot of issues when first starting out with plugins. The Qt documentation here:

    http://qt-project.org/doc/qt-4.8/plugins-howto.html

    has the following instruction step for creating a plugin:

    "Define a set of interfaces (classes with only pure virtual functions) used to talk to the plugins."

    This is a little misleading as the "interface" you create for your plugin does *not* have to be pure virtual. It can have defined functions, and the plugin can reimplement select ones.

  4. #4
    Join Date
    Mar 2008
    Posts
    44
    Thanks
    2
    Platforms
    Unix/X11 Windows

    Default Re: plugins with separate windows

    Thanks all so far,

    My issue is not as much that I cannot load the plugin, I understand the standard example. My issue
    is twofold:
    a. when having selected a certain decoder, I want to be able to interact with a set of buttons and sliders on a screen, however, without
    the main program having any knowledge of it (plugins, i.e. it should be possible to add decoders, without the main program having to
    know on beforehand that such a decoder even exists)
    b. When deallocating a decoder and creating a new decoder I want to have a fresh screen with the visuals of the new decoder. Is it possible to design
    a screen for such a plugin (to be embedded on a fixed location in the main screen) using the designer

    A pointer to any example (not begin the standard brushes etc plugin) would be appreciated

    best
    jan

  5. #5
    Join Date
    Dec 2012
    Posts
    90
    Thanks
    5
    Thanked 20 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: plugins with separate windows

    a. when having selected a certain decoder, I want to be able to interact with a set of buttons and sliders on a screen, however, without
    the main program having any knowledge of it (plugins, i.e. it should be possible to add decoders, without the main program having to
    know on beforehand that such a decoder even exists)
    See the second part of my previous post. Here I elaborate a little.
    Qt Code:
    1. class MainWindow {
    2.  
    3. public:
    4.  
    5. void loadPlugin () {
    6. // here you load plugin
    7. PluginInterface *loadedPlugin = doLoad ();
    8. // Now call defined in the interface method to create widget that contains
    9. // buttons and sliders specific for that plugin
    10. QWidget pluginWindow = loadedPlugin->createPluginWindow ();
    11. // And add this widget to our mainwindow
    12. // Of course you can add specific widget(say QFrame) to be the exact container for child
    13. // widget (with plugin controls)
    14. pluginWindow->setParent(this);
    15. this->ui->centralLayout->addWidget (pluginWindow);
    16. // After that you'll have plugin-specific set of controls ins widget of choice
    17. // Let's just save pointer for subsequent deletion
    18. this->plugWindow= pluginWindow;
    19. };
    20.  
    21. };
    22.  
    23.  
    24. class PluginInterface {
    25.  
    26. public:
    27. QWidget * createPluginWindow () {
    28. // here you can return QWidget window created in designer beforehand
    29. // It's irrelevant if you want stand-alone window or a widget being a part of the ui
    30. // the return type is the same
    31. // This widget will encapsulate all controls specific for the concrete plugin
    32. return new MyPluginWindow;
    33. };
    34. };
    To copy to clipboard, switch view to plain text mode 

    b. When deallocating a decoder and creating a new decoder I want to have a fresh screen with the visuals of the new decoder. Is it possible to design
    a screen for such a plugin (to be embedded on a fixed location in the main screen) using the designer
    As I already said, you can place QFrame or QWidget in place where you want your plugin and the add plugin widget as a child widget to it.
    Deletion is quite straightforward:
    Qt Code:
    1. class MainWindow {
    2. public:
    3. void cleanUp (){
    4. // here we clean up
    5. this->plugWindow->deleteLater ();
    6. // and can load another plugin
    7. this->loadPlugin ();
    8. // After that the widget gets deleted and a new one will be added
    9. };
    10. };
    To copy to clipboard, switch view to plain text mode 

  6. The following user says thank you to lanz for this useful post:

    janK (20th May 2013)

Similar Threads

  1. Separate Classes for Windows
    By Atomic_Sheep in forum General Programming
    Replies: 2
    Last Post: 14th January 2013, 12:21
  2. Replies: 1
    Last Post: 6th June 2012, 01:41
  3. Qt Designer Must designer plugins be separate libraries?
    By Mookie in forum Qt Tools
    Replies: 0
    Last Post: 30th November 2011, 00:39
  4. Load Plugins on Windows
    By ruben.rodrigues in forum Qt Programming
    Replies: 8
    Last Post: 13th May 2011, 07:39
  5. Application Plugins in Windows [XP]
    By dcurtis in forum Installation and Deployment
    Replies: 10
    Last Post: 9th February 2007, 03:01

Tags for this Thread

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.