Is it possible for either the left or right dock areas to have full height of their side rather than having the bottom take the full width?

It is possible to get what you are looking for, but you have to be kind of sneaky about it. The real trick is to have a QMainWindow [doc.qt.nokia.com] as the central widget of your QMainWindow and then dock bottom QDockWidget [doc.qt.nokia.com] in there. Then you can disable the the bottom dock area for your toplevel QMainWindow and dock the left and right dock windows there. We do this trick with Linguist to get a very similar look, so you can check out Linguist [doc.qt.nokia.com] to see how it works there.

The example below is a demonstration of how this can be done.

  1. #include <QtGui>
  2.  
  3. class MainWindow : public QMainWindow
  4. {
  5. public:
  6.  
  7.   MainWindow(QWidget *parent = 0) : QMainWindow(parent)
  8.   {
  9.     QMainWindow *window = new QMainWindow(this);
  10.     window->setCentralWidget(new QTextEdit(window));
  11.     window->setWindowFlags(Qt::Widget);
  12.     setCentralWidget(window);
  13.  
  14.     QDockWidget *dw = new QDockWidget(window);
  15.     dw->setWidget(new QTextEdit(dw));
  16.     window->addDockWidget(Qt::BottomDockWidgetArea, dw);
  17.  
  18.     QDockWidget *dockMain = new QDockWidget(this);
  19.     dockMain->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
  20.     addDockWidget(Qt::LeftDockWidgetArea, dockMain);
  21.     addDockWidget(Qt::RightDockWidgetArea, new QDockWidget(this));
  22.     dockMain->setWidget(new QLabel("The left dock area", dockMain));
  23.   }};
  24.  
  25.   int main(int argc, char **argv)
  26.   {
  27.     QApplication a(argc, argv);
  28.     MainWindow w;
  29.     w.show();
  30.     return a.exec();
  31.   }
  32.  

No comments

Write a comment

Sorry, you must be logged in to post a comment.