July 23, 2011

revellix revellix
Lab Rat
3 posts

How to display Widgets in the midle of a Window

 

Following problem:

I want to display a widget in the middle of a QMdiSubWindow. I also want to use Tabs later. Therefore I add a QStackWidget to a QMdiSubWindow. The first QStackWidget is a Widget I constructed called inAOrifice. Now in the Fullscreenmode the inAOrifice Widget isnt that big and I want to display it in the middle of the QMdiSubWindow, in the QStackWidget respectively. It always appears in the left upper corner. Any suggestions? I have tried a lot already. Cant see my mistake…

Most common code yet …

  1. MainChild::MainChild(QWidget *parent) : QMdiSubWindow(parent)
  2. {
  3.     this->setAttribute(Qt::WA_DeleteOnClose);
  4.  
  5.     inAOrifice = new inputAOrifice(this);
  6.     stackLayout = new QVBoxLayout(this);
  7.     stackWidget = new QStackedWidget;
  8.  
  9.     stackWidget->addWidget(inAOrifice);
  10.     stackLayout->setAlignment(stackWidget,Qt::AlignCenter);
  11.     this->setWidget(stackWidget);
  12.  
  13. }

EDIT:

isnt it used when I call with parent widget…

stackLayout = new QVBoxLayout(this);

I already tried to set the Layout with

this->setLayout…. no effect. the widget doesnt appear.

1 reply

July 23, 2011

Eddy Eddy
Area 51 Engineer
1573 posts

You didn’t use stackLayout.

 Signature 

Moderator
Qt Certified Specialist
Nokia Qt Ambassador

 
  ‹‹ Barcode generation on Windows and Linux [Solved]      [Solved] How to switch architecture from 32bit to 64bit for gcc4.4 ››

You must log in to post a reply. Not a member yet? Register here!