I had a QWidget displaying a complex layout containing many widgets.

The code was approximately:

Qt Code:
  1. #ifndef Q_OS_MAC
  2. QMenuBar *newMenu = createMenus();
  3. outerLayout->addWidget(newMenu);
  4. #endif
  5.  
  6. QHBoxLayout * h_layout = new QHBoxLayout;
  7. h_layout->setContentsMargins(0,0,0,0);
  8. h_layout->setSpacing(0);
  9. h_layout->addWidget(newDocumentsDocklet);
  10. h_layout->addWidget(newEditorsDocklet);
  11.  
  12. outerLayout->addLayout(h_layout);
  13. window->setLayout(outerLayout);
To copy to clipboard, switch view to plain text mode 

This is the result:

01MCm.png

Unfortunately, when I changed my h_layout from QHBoxLayout to QSplitter, the QMenuBar changed its height. I don't understand if this is a bug, as I thought the the QMenuBar had a specific height.

The new code looks like this:

Qt Code:
  1. #ifndef Q_OS_MAC
  2. QMenuBar *newMenu = createMenus();
  3. outerLayout->addWidget(newMenu);
  4. #endif
  5.  
  6. QSplitter * h_layout = new QSplitter;
  7. h_layout->setOrientation(Qt::Horizontal);
  8. h_layout->addWidget(newDocumentsDocklet);
  9. h_layout->addWidget(newEditorsDocklet);
  10.  
  11. outerLayout->addWidget(h_layout);
  12. window->setLayout(outerLayout);
To copy to clipboard, switch view to plain text mode 

This is the new rendering:

KCU9e.png

Is somebody able to help me understand why this has happened? And a way to solve this?