1. 直接添加到Scene
QGraphicsScene *scene = new QGraphicsScene;
QLineEdit *lineEdit = new QLineEdit("Hello");
QGraphicsProxyWidget *proxy = scene->AddWidget(lineEdit);
2. 放到Item中
MyQGraphicsItem *item = new MyQGraphicsItem;
QLineEdit *lineEdit = new QLineEdit("Hello");
QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(item);
proxy->setWidget(lineEdit);
//控制大小 控件:setFixedSize() proxy:setMaximumSize()
评论区