QObjects と (たとえば) QGraphicsWidgets のツリーのような構造を持つことは可能ですか? つまり、次のような初期化リストを書くことはできません。
class MyButton : public QGraphicsWidget
{
Q_OBJECT
public:
MyButton(int buttonId, QObject *parent = 0) : QObject(parent)
{
}
そして、のようになります
myButton = new MyButton(id, myObject);
私は .setParent または何をすべきですか?
更新:実際の割り当てを参照してください:
class myObject : public QObject
{
Q_OBJECT
public:
MyObject(QObject *parent = 0) : QObject(parent) {
}
MyButton *myButton;
void showButton(){
myButton = new MyButton(id, this); //no matching function for call to 'MyButton::MyButton(MyObject* const)'
//note: no known conversion for argument from 'MyObject* const' to 'QGraphicsObject*'
}
};