Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Graphicsview and pushbuttons
Forum Updated to NodeBB v4.3 + New Features

Graphicsview and pushbuttons

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • mit_cruzeM Offline
    mit_cruzeM Offline
    mit_cruze
    wrote on last edited by
    #1

    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.

    Thanks

    raven-worxR 1 Reply Last reply
    0
    • mit_cruzeM mit_cruze

      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.

      Thanks

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @mit_cruze said in Graphicsview and pushbuttons:

      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.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • mit_cruzeM Offline
        mit_cruzeM Offline
        mit_cruze
        wrote on last edited by
        #3

        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?

        1 Reply Last reply
        0
        • m.sueM Offline
          m.sueM Offline
          m.sue
          wrote on last edited by
          #4

          The buttons are probably all at the same position; so you see only one.

          1 Reply Last reply
          2
          • mit_cruzeM Offline
            mit_cruzeM Offline
            mit_cruze
            wrote on last edited by
            #5

            yeah thats right! :)

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved