Custom widget can't show in layout
Solved
Qt 6
-
I code a custom widget and put it in the main layout in my mainwindow class .
But It can't show properly as below:
the blank part should be the custom widget.
I change the code generate by ui file from:graphicsView = new MainViewer(aaa); graphicsView->setObjectName(QString::fromUtf8("graphicsView")); gridLayout->addWidget(graphicsView, 3, 1, 1, 1); MainWindow->setCentralWidget(aaa);
to:
graphicsView = new MainViewer(aaa); graphicsView->setObjectName(QString::fromUtf8("graphicsView")); //gridLayout->addWidget(graphicsView, 3, 1, 1, 1); MainWindow->setCentralWidget(aaa);
I can get a floating custom widget as below:
And if I set the custom widget as central widget, It also work well.So, what may be the problem when I put the custom widget into a layout?
-
Hi
There is no special requirements for a custom widget to be used in a layout but maybe it get compressed to zero in size
so try for test to do
mywidget->setMinimumSize(100,100) and see.