小编dav*_*ave的帖子

使QGraphicsProxyWidget可移动和可选

我想把a QWidget放入一个QGraphicsView并通过使用使小部件可选择和移动QGraphicsProxyWidget.(这完全适用QGraphicsRectItem,QGraphicItem等等)

这是我目前使用的代码:

// Create new QGraphicsScene and assign to graphicsView
scene = new QGraphicsScene(this);
ui->graphicsView->setScene(scene);

// Create widget and add to scene
MyWidget *widget = new MyWidget;
QGraphicsProxyWidget *proxy = scene->addWidget(widget);

// Make selectable
proxy->setFlag(QGraphicsItem::ItemIsSelectable, true);
// Make movable
proxy->setFlag(QGraphicsItem::ItemIsMovable, true);
Run Code Online (Sandbox Code Playgroud)

小部件显示正确,但它既不可移动也不可选择!

任何帮助将不胜感激 ;)

c++ qt

4
推荐指数
2
解决办法
3481
查看次数

标签 统计

c++ ×1

qt ×1