侧边栏壁纸
博主头像
三味的小站博主等级

世界上没有偶然,有的只是必然的结果。

  • 累计撰写 61 篇文章
  • 累计创建 13 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录
Qt

QGraphicsItem中添加控件

三味线
2019-06-20 / 0 评论 / 0 点赞 / 13 阅读 / 723 字

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()

0

评论区