correct qt approach
-
Hello!!
Im new to qt, so i need to wrap my head about how code in qt way, i coded some gui based apps, so far so good, but now i wanted to code "graphics" and im a bit lost on how to do that as with gui ones is easy as you get a layout, place widgets, etc etc.
This is what im currently doing.
Im loading a small video file, extracting frames to pointer of a vector of QPixmap objects, later i pass that vector to a class where i have a Qtimeline object to play that qpixmap secuence.
So i have N instances of a class that contains a vector of QPixmap and a timeline to play those, just like a image secuence.
My problem is, how i can draw N instances of that class in a MxN shaped grid at window? From the framework i come from i will just pass some coords to pixmap draw and thats it.
For example, should i need to use a QGraphicsScene as a canvas where i can place N QGraphicsPixmapItem? and later how to draw that canvas to main window?
As you can see im a bit lost on how qt works so i will appreciate any help here :)
Regards
-
Hi
QGraphicsScene might not be a bad choice if you need scrolling /panning etc.
You use qgraphicsview to show anything you put into a scene. The scene is nonvisual.How big are these pixmaps ?
as a note.
You can draw in Qt by having a QWidget and overriding its paint event. Then use QPainter to draw
what you want. QPainter has a rich api. -
Hi
Pixmaps are small, 90x70 pxs, i don't need scroll or panning....seems i was choosing wrong..... Maybe is better to explain my goal so can propose me the best way.
I want to draw the same video N times on the window and to have independent control on each one, imagine a 5x5 grid and in each cell i want to draw the video and each cell have independent playback from others....
The video content is the same for all cells, even the video is small size i don't want to create 25 objects of mediaplayer and load same file on each one....
So what i'm doing is to extract all the video frames to a vector of pixmaps and later share that vector among N classes where i use a qtimeline to control playback. That way i only load content to memory once and share that frames that i can control independent in each class.
This point is clear.
What im missing is what is the best approach to draw that content.
Thank you