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 [] as the central widget of your QMainWindow and then dock bottom QDockWidget [] 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 [] to see how it works there.

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

  1. #include <QtGui>
  3. class MainWindow : public QMainWindow
  4. {
  5. public:
  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);
  14.     QDockWidget *dw = new QDockWidget(window);
  15.     dw->setWidget(new QTextEdit(dw));
  16.     window->addDockWidget(Qt::BottomDockWidgetArea, dw);
  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.   }};
  25.   int main(int argc, char **argv)
  26.   {
  27.     QApplication a(argc, argv);
  28.     MainWindow w;
  30.     return a.exec();
  31.   }

No comments

Write a comment

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