我想子類一個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