Personal tools
You are here: Home Forum How to use Salome? How to dock custom windows

How to dock custom windows

Up to How to use Salome?
  • How to dock custom windows

    Posted by Alex Grosu at April 24. 2008
    Hello
    First of all, I want to say that you did a great work with this product.
    Second, please, bare with me, because I'm a totally newbie in Salome.
    I am trying to learn Salome in order to develop a new component.  In order to do this, I have to integrate some windows in Salome's work area. I want  to dock my custom windows in the same manner as ObjectBrowser or PythonConsole are. I will need to "dock" (or display) 3 custom windows. I will need also to display an OCC Viewer to draw a sphere (for this I saw the steps in the tutorial documentation). From my 3 custom windows (which will have buttons and edit lines) I will popup some other windows, but this is some other story. What I need is to understand how can I dock my custom windows (derived from QDialog) into Salome's work area. I will need to hide ObjectBrowser and PythonConsole, but this was easy to do Can you please point me an example or some documentation? I'm reading for almost 3 days and I can't "catch" the problem
    Thank you a lot for your time reading this
    Have a good day, Alex
     
    • Re: How to dock custom windows

      Posted by Vadim SANDLER at May 21. 2008
      Hello Alex,

      In order to create dock windows in GUI, you have to use Qt's QDockWindow class. For example:
      // create dock window and set its attributes
      QDockWindow* dw = new QDockWindow( QDockWindow::InDock, desktop() );
      dw->setResizeEnabled( true );
      dw->setCloseMode( QDockWindow::Always );
      dw->setName( "My Dock Window" );
      // move dock window to the proper area
      desktop()->moveDockWindow( dw, QMainWindow::DockLeft );
      // create your widget using dock window as parent
      MyWidget * mw = new MyWidget( dw );
      ...
      // set your widget as main widget of the dock window
      dw->setWidget( mw );

      For the same goal you can use LightApp_WidgetContainer class from LightApp package which implements dock window support for the LightApp-based modules. Please, refer Qt documentation and LightApp_WidgetContainer sources for more details. You can also look at LightApp_Application class for examples of LightApp_WidgetContainer usage.

      Unfortunately, Qt 3 does not allow using QDialog objects as child widgets of the QDockWindow class. You have to subclass QWidget or any other widget class to implement your own dock window functionality.

      Regards,
      Vadim.
      • Re: How to dock custom windows

        Posted by Alex Grosu at May 21. 2008
        Vadim SANDLER wrote:
        Hello Alex,

        In order to create dock windows in GUI, you have to use Qt's QDockWindow class. For example:
        // create dock window and set its attributes
        QDockWindow* dw = new QDockWindow( QDockWindow::InDock, desktop() );
        dw->setResizeEnabled( true );
        dw->setCloseMode( QDockWindow::Always );
        dw->setName( "My Dock Window" );
        // move dock window to the proper area
        desktop()->moveDockWindow( dw, QMainWindow::DockLeft );
        // create your widget using dock window as parent
        MyWidget * mw = new MyWidget( dw );
        ...
        // set your widget as main widget of the dock window
        dw->setWidget( mw );

        For the same goal you can use LightApp_WidgetContainer class from LightApp package which implements dock window support for the LightApp-based modules. Please, refer Qt documentation and LightApp_WidgetContainer sources for more details. You can also look at LightApp_Application class for examples of LightApp_WidgetContainer usage.

        Unfortunately, Qt 3 does not allow using QDialog objects as child widgets of the QDockWindow class. You have to subclass QWidget or any other widget class to implement your own dock window functionality.

        Regards,
        Vadim.


        Hello Vadim
        Thank you a lot for your information! Finally, I've succeeded few weeks ago to understand that only using QDockWindow I'll be able to dock widgets on Salome's desktop.  Your example is great, I'll follow it. Also, you gave me a valuable info about LightApp_WidgetContainer.
        Have a great day,
        Alex
Powered by Ploneboard
Document Actions