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. [Solved]QGraphicsScene | QGraphicsView
Forum Updated to NodeBB v4.3 + New Features

[Solved]QGraphicsScene | QGraphicsView

Scheduled Pinned Locked Moved General and Desktop
11 Posts 4 Posters 10.3k 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.
  • C Offline
    C Offline
    candidinho
    wrote on last edited by
    #1

    Hi:
    How can i see the whole scene into a qgraphicsview?
    I add a videowidget into a qgraphicsScene and i see a part of it.

    Help please.

    Thanks.

    1 Reply Last reply
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #2

      did you do it like this?

      @ QGraphicsScene scene;
      scene.addText("Hello, world!");

      QGraphicsView view(&scene);
      view.show();@

      normally your view will show your scene entirely.

      Qt Certified Specialist
      www.edalsolutions.be

      1 Reply Last reply
      0
      • T Offline
        T Offline
        thisisbhaskar
        wrote on last edited by
        #3

        you either decrease the size of scene to fit in to view ( QGraphicsScene::setSceneRect ) or increase size of view to show whole scene(QGraphicsView::setGeometry).

        See http://doc.qt.nokia.com/latest/graphicsview.html

        1 Reply Last reply
        0
        • C Offline
          C Offline
          candidinho
          wrote on last edited by
          #4

          It didn't work.
          My basic code are:
          @media = new Phonon::MediaObject(this);
          video1 = new Phonon::VideoWidget();
          Phonon::createPath(media, video1);
          media->setCurrentSource(QString("f:/video.mp4"));
          scene=new QGraphicsScene(this);
          proxy=scene->addWidget(video1);
          ui->view->setScene(scene);@

          I try with setSceneRect, setGeometry and the result it's the same! Also i try to setSceneRect with a QRect with a size more bit than the scene. Don't change anything.

          My problem is that:
          !https://picasaweb.google.com/lh/photo/fDUs-LsA56F1HAtu73h6Y_qnZ-C2WzuLKdXNJBFn8lk?feat=directlink()!

          But, i want:
          !https://picasaweb.google.com/lh/photo/bMFSNFK_JQE2WprGFZ3vKvqnZ-C2WzuLKdXNJBFn8lk?feat=directlink()!

          Could i set any special property in QtDesigner?

          1 Reply Last reply
          0
          • L Offline
            L Offline
            ludde
            wrote on last edited by
            #5

            Not sure setSceneRect or setGeometry is what you want to do. Have you tried fitInView()?

            1 Reply Last reply
            0
            • C Offline
              C Offline
              candidinho
              wrote on last edited by
              #6

              Yes, I try it. With it videowidget has a size about 40x40 pixeles. I see it too small into the center of the scene.
              I think that any inherit size is missing or bad between proxywidget and qgraphicsscene. Or the proxywidget don't handle any signal or event.

              If you want to see my code. See http://pastie.org/2145987

              1 Reply Last reply
              0
              • L Offline
                L Offline
                ludde
                wrote on last edited by
                #7

                Had a quick look at your code.
                Cannot see why ui->view->fitInView(proxy,Qt::KeepAspectRatioByExpanding) should not do what you want. Just curious - why are you resizing video1 to half its size? And you could add some more debug output showing the bounding rect of proxy, for example.
                Also, from your pictures, it is a bit unclear why you need the graphicsview at all. Are you planning to add other things to it than just the video widget?
                Apart from that, I'm not sure I can be of more help, sorry.

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  candidinho
                  wrote on last edited by
                  #8

                  I need to show some text above the videowidget(it's a videosubtitle software). If i can do this in a easy way, i want to know it.
                  Thanks Ludde.

                  1 Reply Last reply
                  0
                  • L Offline
                    L Offline
                    ludde
                    wrote on last edited by
                    #9

                    To just add subtitles, I would probably create a subclass of Phonon::VideoWidget, override its paintEvent(), and draw the text using QPainter::drawText() after letting the VideoWidget draw the video. Have never used the Phonon classes, though, but cannot see why it would not work.

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      candidinho
                      wrote on last edited by
                      #10

                      Now it's working properly. I reimplement the resizeEvent of the Widget with view->fitinview(proxy,Qt:keepaspectratio). But at start the videowidget it's too small. When i resize the window it takes properly size. Any idea?
                      Thanks.

                      1 Reply Last reply
                      0
                      • L Offline
                        L Offline
                        ludde
                        wrote on last edited by
                        #11

                        The only thing I can think of is that the videowidget might not get its size until after you've put it in the scene.

                        But I still cannot see why you want to use QGraphicsView for this. You can do your own painting on/in any widget. QGraphicsView is great for keeping track of large numbers of individual grahpical items, but does not really help you that much if you just want to put text on top of a video.

                        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