在qdesigner_workbench.cpp文件中,我如何通过代码向FormWindow添加一个小部件(例如QLabel)?
由于createWidget()等方法都是抽象的,我该如何正确地使用内部机制将QLabel添加到活动的FormWindow中?
编辑: 在qdesigner_workbench.cpp文件中,这是我目前拥有的内容:
设计师中有9个小部件,你可以看到上面提到了9个数组; 可以查看此链接(一个图像)进行说明。 http://img24.imagevenue.com/img.php?image=98871_a_122_476lo.jpg 那么...我该如何正确地添加QLabel小部件? 尝试过两种方式:
据报道,似乎两个作品都可以。
编辑: 在qdesigner_workbench.cpp文件中,这是我目前拥有的内容:
QDesignerFormWindowManagerInterface* fwm = core()->formWindowManager();
QDesignerFormWindowInterface* fw = fwm->activeFormWindow();
QWidget* mw = fw->mainContainer();
QLabel* label = new QLabel(mw); //can be added correctly but not in the right hierarchy
label->setText("I am a good girl.");
mw(从fw -> mainContainer()获得)实际上是一个MainWindow,但我需要的真正数据在:
mw -> children[2] (which is a QDesignerWidget) -> children
设计师中有9个小部件,你可以看到上面提到了9个数组; 可以查看此链接(一个图像)进行说明。 http://img24.imagevenue.com/img.php?image=98871_a_122_476lo.jpg 那么...我该如何正确地添加QLabel小部件? 尝试过两种方式:
QLabel* label = new QLabel(fw); // will be a sibling of MainContainer, which is the QMainWindow (mw) in this case
QLabel* label = new QLabel(mw); // will be a sibling of QDesignerWidget
据报道,似乎两个作品都可以。