Results 1 to 6 of 6

Thread: Dock of dock

  1. #1
    Join Date
    Aug 2012
    Location
    Paris
    Posts
    15
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Dock of dock

    Dear Sirs,


    I'm using Qt for a software project I recently started, and the development is in a good way... this tool is fantatic, and the Qt creator IDE so friendly...

    However, I would have a question concerning the windows:
    I currently use around 8 dock windows, and I would like to display them in 2 'screen large' separate windows (4 docks in each), and to have the possibility to chose the current large window which would display the 4 docks (by the menu, or whatever).

    I was thinking about using 2 large docks and trying to dock 4 windows inside both, impossible, because the addDockWidget function can't be used on docks...
    I was also waondering if there would be a possibility to create 2 main windows...

    If you would have any type, please, let me know !

    Thanks in advance,

    Best Regards,

    Stéphane


    Added after 1 4 minutes:


    PS:
    I just discovered that it could probably be possible using this:

    Qt Code:
    1. #include <QtGui>
    2. #include <QDebug>
    3.  
    4. // #include "main.moc"
    5.  
    6. class Window: public QMainWindow
    7. {
    8. Q_OBJECT
    9. public:
    10. Window(QWidget *p = 0): QMainWindow(p) {
    11. count = 0;
    12. central = new QLabel(this);
    13. setCentralWidget(central);
    14. }
    15. public slots:
    16. void receive() {
    17. central->setText(QString::number(count++));
    18. }
    19. private:
    20. QLabel *central;
    21. int count;
    22. };
    23.  
    24. class Controller: public QObject {
    25. Q_OBJECT
    26. public:
    27. Controller(QObject *parent = 0): QObject(parent) {
    28. m_winA = new Window();
    29. m_winA->setWindowTitle("Window A");
    30. connect(this, SIGNAL(signalA()), m_winA, SLOT(receive()));
    31.  
    32. m_winB = new Window();
    33. m_winB->setWindowTitle("Window B");
    34. connect(this, SIGNAL(signalB()), m_winB, SLOT(receive()));
    35.  
    36. m_winA->show();
    37. m_winB->show();
    38.  
    39. // some fake incoming events
    40. m_count = 0;
    41. connect(&m_timer, SIGNAL(timeout()), this, SLOT(incoming()));
    42. m_timer.start(100);
    43. }
    44. ~Controller() {
    45. delete m_winA;
    46. delete m_winB;
    47. }
    48. public slots:
    49. void incoming() {
    50. if (m_count++ % 3 == 0)
    51. emit signalA();
    52. else
    53. emit signalB();
    54. }
    55. signals:
    56. void signalA();
    57. void signalB();
    58. private:
    59. Window *m_winA;
    60. Window *m_winB;
    61.  
    62. int m_count;
    63. QTimer m_timer;
    64. };
    65.  
    66. int main(int argc, char *argv[])
    67. {
    68. QApplication app(argc, argv);
    69. Controller c;
    70. return app.exec();
    71. }
    72.  
    73. //
    To copy to clipboard, switch view to plain text mode 

    However, it creates 2 separate windows...
    Last edited by Rakma74; 19th August 2012 at 18:29.

  2. #2
    Join Date
    Aug 2012
    Location
    Paris
    Posts
    15
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Dock of dock

    Here you are the best example of what I would like to do:

    http://qgroundcontrol.org/screenshots (done with Qt, so it should be possible)

    At the top left, there is an index with few buttons, and when clicked it display new large windows (screen size) with dock windows inside...

    Hope it gives you some indications about my wish...

    Best Regards,

    Stéphane

  3. #3
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    503
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Dock of dock

    Hi, you create two instances of Window in Controller::Controller(), and since none of them has a parent, both become windows (see QWidget::QWidget).

    Ginsengelf

  4. #4
    Join Date
    Aug 2012
    Location
    Paris
    Posts
    15
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Dock of dock

    Thanks for your answer, I tried with the same parent, without success... Always 2 windows...

    I finally found the solution using this strategy:

    1 QMainWindow <-- 1 DockWidgets <-- 1 QMainWindow <-- n DockWidgets
    same QMainWindow <-- 1 DockWidgets <-- 1 QMainWindow <-- n DockWidgets

    Qt Code:
    1. #include <QtGui>
    2. #include <QDebug>
    3.  
    4. #include "main.h"
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QApplication app(argc, argv);
    9.  
    10.  
    11. QMainWindow *main_window;
    12. main_window = new QMainWindow;
    13.  
    14. // 2 DOCK WIDGETS FOR THE MAIN WINDOW
    15.  
    16. // N DOCK WIDGETS FOR THE MAIN WINDOWS OF THE 2 DOCK WIDGETS
    17. QDockWidget *sub_dock;
    18.  
    19.  
    20. // MAIN DOCK 1 -----------------------------------------------
    21.  
    22. dock = new QDockWidget("W1", main_window);
    23.  
    24. QMainWindow *Sub_window1;
    25. Sub_window1 = new QMainWindow;
    26. dock->setWidget(Sub_window1);
    27.  
    28. main_window->addDockWidget(Qt::TopDockWidgetArea, dock);
    29.  
    30. // -----------------------------------------------------------
    31.  
    32.  
    33. // 2 dock widgets to be added to the MAIN DOCK 1
    34. QWidget *widg1;
    35. QWidget *widg2;
    36.  
    37. sub_dock = new QDockWidget("SW1", Sub_window1);
    38. widg1 = new QWidget;
    39. sub_dock->setWidget(widg1);
    40. Sub_window1->addDockWidget(Qt::TopDockWidgetArea, sub_dock);
    41.  
    42. sub_dock = new QDockWidget("SW2", Sub_window1);
    43. widg2 = new QWidget;
    44. sub_dock->setWidget(widg2);
    45. Sub_window1->addDockWidget(Qt::TopDockWidgetArea, sub_dock);
    46.  
    47.  
    48.  
    49. // MAIN DOCK 2 -----------------------------------------------
    50.  
    51. dock = new QDockWidget("W2", main_window);
    52.  
    53. QMainWindow *Sub_window2;
    54. Sub_window2 = new QMainWindow;
    55. dock->setWidget(Sub_window2);
    56.  
    57. main_window->addDockWidget(Qt::TopDockWidgetArea, dock);
    58.  
    59. // -----------------------------------------------------------
    60.  
    61.  
    62. main_window->show();
    63.  
    64.  
    65. return app.exec();
    66. }
    To copy to clipboard, switch view to plain text mode 


    Thanks for all !!

    Best Regards,

    Stéphane


    Added after 1 58 minutes:


    Sorry, I have another question.

    How would it be possible to dock 2 Dock windows (in a QMainWindow) with this property: each dock would take the whole QMainWindow size, and we could switch from a dock to another by clicking on their name.

    To do that, I have to move the dock manually with the mouse, I would like to know if it is possible on start...

    Thanks in advance,

    Stéphane
    Last edited by Rakma74; 20th August 2012 at 18:41.

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Dock of dock

    Sounds like the QMainWindow::AllowTabbedDocks (the default) and/or QMainWindow::ForceTabbedDocks option. See setDockOption().

    If you do not intend that the user is able to float these widgets off in their own windows then it looks like your whole design would be better matched by a QStackedWidget containing a series of QTabWidget pages containing what you are currently placing in the dock widgets.

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

    Rakma74 (21st August 2012)

  7. #6
    Join Date
    Aug 2012
    Location
    Paris
    Posts
    15
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Dock of dock

    Thanks so much for your answer, this is exactely what I was looking for.

    However, I tried with this code
    Qt Code:
    1. // Force the 2 main dock windows to be tabbed
    2. main_window->setDockOptions(QMainWindow::ForceTabbedDocks);
    To copy to clipboard, switch view to plain text mode 

    without success... There seems to be a bug from Qt
    https://bugreports.qt-project.org/br...s:all-tabpanel

    Fortunately, another post, I just found thanks to your answer, gave me the solution :
    http://www.qtcentre.org/threads/8566...ceTabbedDocks)

    So, now I do this :

    Qt Code:
    1. // 2 DOCK WIDGETS FOR THE MAIN WINDOW
    2. QDockWidget *dock1;
    3. QDockWidget *dock2;
    4.  
    5. ... ...
    6.  
    7. main_window->tabifyDockWidget(dock1, dock2);
    To copy to clipboard, switch view to plain text mode 

    Thanks for all,

    Stéphane


    Added after 54 minutes:


    Important : On Startup, W2 was visible by default, and I wanted W1 to be visible...

    It can be done with the following command:

    // Make first main dock window visible
    dock1->raise();

    Best Regards,

    Stéphane
    Last edited by Rakma74; 21st August 2012 at 12:11.

Similar Threads

  1. OSX remimplement Dock Quit.
    By migel in forum Newbie
    Replies: 0
    Last Post: 20th April 2012, 17:13
  2. Programmatically Dock
    By venkateshhegde in forum Newbie
    Replies: 4
    Last Post: 14th February 2011, 01:35
  3. What's a 'Dock' and...
    By Patrick Sorcery in forum Newbie
    Replies: 1
    Last Post: 27th August 2010, 06:40
  4. forcing dock windows to dock?
    By eric_vi in forum Qt Programming
    Replies: 3
    Last Post: 9th August 2009, 16:32
  5. Dock Nesting Problem
    By blaylockr in forum Newbie
    Replies: 4
    Last Post: 14th August 2008, 14:59

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.