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 …
Code:
MainChild
::MainChild(QWidget *parent
) : QMdiSubWindow
(parent
){
this->setAttribute(Qt::WA_DeleteOnClose);
inAOrifice = new inputAOrifice(this);
stackWidget->addWidget(inAOrifice);
stackLayout->setAlignment(stackWidget,Qt::AlignCenter);
this->setWidget(stackWidget);
}
Re: How to display Widgets in the midle of a Window
One bug that I see is that you don't seem to add any items in your layout, so centering it does not help. You probably need to add your "orifice" into it.
Re: How to display Widgets in the midle of a Window
For you custom widget to be centered, you need to create an empty QWidget, set a layout on to the empty widget, add custom widget on to the layout, and set center alignment to the custom widget, something like this.
Code:
QWidget * inAOrifice
= new inputAOrifice
(widget
);
layout->addWidget(inAOrifice);
layout->setAlignment(inAOrifice, Qt::AlignCenter);
// now add widget to the stacked widget
Re: How to display Widgets in the midle of a Window
Santosh Reddy... very big thanks!!!!