我想在 QGraphicsView 中移动 QPushButton 或某种 QWidget,例如 QListWidet、QTableWidget 等。
所以,我使用了 QGraphicsProxyWidget。
然后我单击小部件并拖动。但它没有动。
我怎样才能移动QWidget?
这是我的代码。
ui->graphicsView->setGeometry(0,0,geometry().width(),geometry().height());
scene = new QGraphicsScene(0, 0, geometry().width(), geometry().height(), this);
ui->graphicsView->setScene(scene);
btn =new QPushButton(NULL);
QGraphicsProxyWidget *proxy = scene->addWidget(btn);
proxy->setFlags(QGraphicsItem::ItemIsMovable|QGraphicsItem::ItemIsSelectable);
scene->addItem(proxy);
Run Code Online (Sandbox Code Playgroud)
你能告诉我出了什么问题吗?
谢谢。