0

I have created an QTabWidget with Tabs. Now I want to set an CentralWidget for an only TabPage, I have tried this with this code:

msgList = new QListWidget(ui->msgTab);
msgList->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

But what I get is this: https://i.stack.imgur.com/jCjuG.png

So how I can set that an "CentralWidget" for the msgTab? And display it in the complete tab and not in the corner.

Regards, Jan

Jan
  • 139
  • 10

1 Answers1

0

You should use layouts. For example:

msgList = new QListWidget();
QVBoxLayout *layout = new QVBoxLayout();
layout->addWidget(msgList);
ui->msgTab->setLayout(layout);

Or you can set layout for the tab in the .ui, then just do:

msgList = new QListWidget();
ui->msgTab->layout->addWidget(msgList);
Oleg Shparber
  • 2,732
  • 1
  • 18
  • 19