2

I have an application utilizing QWinWidget in a Win32 window. I'd like to add DockWidgets and the associated behaviour to it. There don't seem to be any exposed APIs for adding custom DockAreas, and the latest docs are sparse beyond adding DockWidgets to a QMainWindow. Older docs imply there once was a public QDockArea class.

So far, my best option appears to be adding a neutered QMainWindow (no top-level status, no frame, etc.) to the QWinWidget and going from there (second source).

I was hoping there was a way to add DockAreas to any container, but it doesn't appear that way. As a side note, QWinWidget is used to have window manager control with our custom frame requirement, but if there's a pure QMainWindow/QWidget way to have the same result (with Qt::FramelessWindowHint), I'd be happy to switch over.

Community
  • 1
  • 1
Nick
  • 4,901
  • 40
  • 61
  • 1
    I'm going the QMainWindow as a child way... and it's really painless. Mysteriously painless, even... – Nick May 06 '15 at 19:09

1 Answers1

0

As I said in the comments, I've added within my QWinWidget in my Win32 window a QMainWindow field. That is:

class QWinWidget : public QWidget
{
  ...
  QMainWidget* mainWidget;
}

QWinWidget::QWinWidget()
{
  mainWidget = new QMainWindow(this);
  mainWidget->setWindowFlags(Qt::Widget); //1
}

Note that while the docs and some forum posts (from this post) indicate you need to set window flags explicitly due to the QMainWindow constructor setting Qt::Window, I tested it without the setWindowFlags() line (marked with //1 above) without noticing anything wrong.

So, this gives me the nice QWinWidget window I spent so much time making, inside a frameless Win32 window, with a QMainWindow child and all the features that brings along with it. Docking, menu bar, status bar, etc.

Community
  • 1
  • 1
Nick
  • 4,901
  • 40
  • 61