我想子类一个QWidget的一个实例入店...让QHBoxLayout,负责在一个QWidget
Widget::Widget(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::ImgWidget)
{
// Is this the right place or does it need to be outside like: Widget::layout...
QHBoxLayout *hLayout = new QHBoxLayout;
...
hLayout->addWidget(someWidget);
this->setLayout(hLayout);
}
...,然后在比如我想添加小部件的布局像
Widget *widget = new Widget();
...
widget->hLayout->addWidget(someOtherWidget);
在Python等效将由像self.layout = QHBoxLayout()
“自我”关键字来完成,但我认为它不能与this
关键字
但更普遍的做...什么为t他在C++中做到这一点的最佳方式,因为我用pyqt做了很多工作
是的。纠正一些拼写btw – tobilocker