Unsolved A custom widget which inherited from QMainwindow can't display in Preview of Qt Desinger
-
-
The custom widget displays well in qt designer, but can't work well in the preview.
-
Whereas it will work well when I change the inherited parent from QMainwindow to Qwidget.
-
-
Did you create a designer plugin or how did you use it in designer?
-
@Christian-Ehrlicher I created this designer plugin by QDesignerCustomWidgetInterface. And It was available when the custom widget inherited from QWidget instead of QMainWindow.
-
Then make sure you defined all correct when you changed from QWidget to QMainWindow.
-
@Christian-Ehrlicher Well. You can see the mainwindow display in the .ui File after the window of Preview, and the tabs and menu works well, but once in the Preview i can't see the mainwindow. And In my code, this custom widget change from QWidget to QMainWindow just need to modify its parent, i don't think i had defined something wrong. Does the plugin mechanism have some rules that can't display a QMainwindow in the Preview?
-
@Christian-Ehrlicher And after I test other widgets, I found QPushButton, QLineEdit.. which in the widget box of qt designer is ok, but like QMainWindow, QMenubar.., they all can display in the qt desginer and can't work in Preview. So that means qt designer can't preview the custom widget which inherits these? Is it a bug or something? Because if these widgets combined in a intance inherited from QWidget, they are ok in the Preview.
-
This post is deleted! -
@Toocold I don't have problems with previewing custom widgets added with a correct designer plugin. Please provide a minimal, compilable example of your plugin.
-
QWidget* TestPlugin::createWidget(QWidget* pParent) { auto pTestWidget = new QWidget(pParent); auto pTestButton = new QPushButton(pTestWidget); pTestButton->setText("Hello"); return pTestWidget; }
Hey, use above code can easily to see a custom widget named "QWidget" previewing in the qt designer.
QWidget* TestPlugin::createWidget(QWidget* pParent) { auto pTestWidget = new QMenuBar(pParent); auto pTestMenu = pTestWidget->addMenu("Hello"); pTestMenu->addMenu("World"); return pTestWidget; }
And if you use the next code block, and modify the
domxml()
,name()
.., you can see it in you qt designer but won't preview, same as QMainWindow.