How can i move the QWidget in QGraphicsView?
Solved
General and Desktop
-
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); ui->graphicsView->setGeometry(0,0,geometry().width(),geometry().height()); scene = new QGraphicsScene(0, 0, geometry().width(), geometry().height(), this); ui->graphicsView->setScene(scene); QPushButton *button =new QPushButton(NULL); button->setText("move it"); scene->addWidget(button); }
Hello, This is my code.
I want to move the QPushButton or kind of QWidget in QGraphicsView for example QListWidet, QTableWidget etc.
So, How can i move QWidget? -
-
-
@jsulm
I already try it. but It is not work ..
This is my code.ui->graphicsView->setGeometry(0,0,geometry().width(),geometry().height()); scene = new QGraphicsScene(0, 0, geometry().width(), geometry().height(), this); ui->graphicsView->setScene(scene); QPushButton *button =new QPushButton(NULL); QGraphicsProxyWidget *proxyItem = new QGraphicsProxyWidget; proxyItem->setWidget(button); proxyItem->setFlag(QGraphicsWidget::ItemIsMovable); scene->addItem(proxyItem);
Can you tell me what is wrong?
-