Graphicsview and pushbuttons
Hello, I want to add pushbuttons in graphicsview. I am already playing video in graphicsview but now I want to add some pushbuttons to it to control video.
I added video using setviewport function.
I added video using setviewport function
Why would you do such crucial thing!?! This is not the intention of the setViewport() method. The viewport is just the widget where the contents of the view are painted on!
The correct way for adding widgets to a QGraphcisView is via
QGraphicsScene::addWidget(). Then you can add the buttons the same way, or you compose a custom QWidget (using QLayouts) and add the buttons there. Then add the whole composed widget to the view.
But anyway when possible avoid the usage of QGraphicsView with QWidgets inside it.
int i = 5 ;
QGraphicsScene * scene = new QGraphicsScene(0,0,480,272);
for(i = 0 ; i < 5 ; i++ )
btnuser[i] = new QPushButton;
btnuser[i]->setText("Test User"); QGraphicsProxyWidget *proxy = scene->addWidget(btnuser[i]); } ui->graphicsView->setScene(scene);
This way I can add only one pushbutton. How Do I add multiple?
The buttons are probably all at the same position; so you see only one.
yeah thats right! :)