은 QObjects 및 (예를 들어) QGraphicsWidgets와 같은 트리 구조를 가질 수 있습니까? 나는이 같은 초기화 목록을 쓸 수 없습니다 의미 :QObject의 자식 인 QGraphicsWidget
class MyButton : public QGraphicsWidget
{
Q_OBJECT
public:
MyButton(int buttonId, QObject *parent = 0) : QObject(parent)
{
}
다음은,
myButton = new MyButton(id, myObject);
어떻게해야 .setParent 또는 무엇처럼?
업데이트 : 난 당신이 그래픽 장면에서 상위/하위 계층의 부모와 parent item
QObject를 같이 parent
혼란 생각
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*'
}
};
아니요, 답을 표시하기 전에 몇 가지 해결 방법이 필요했습니다. 하지만 아마 당신 말이 맞아요. 그러한 계층을 구축 할 방법이 없습니다. –
@DensiTensy : 대답에 쓰인대로 setParent가 있습니다. :) – lpapp