I am trying to make a simple QT android app, but basically my problem is that on my main screen I have about 250 little images that i want to scroll. But I really need the scrolling to be fluent and fast. First I tried it using QML but it wasnt really fast, then I tried to make the app in qt designer and use widgets but that was very slow. Then I tried using openGL but on android I can only use openGL ES and I cant find so much examples because every example that I find is much more advanced than I need.
But basically my main question is, what do you think is the best way to solve my problem and if its openGL which way of using it is the best that could solve it?
Thank you.
Neither approach should have problems when scrolling when compared to a native application on the same device. Check the following:
Make sure to measure performance only in release-builds, with QML debugging disabled and no debugger attached.
Maybe your device simply can't keep up with so many images in one view - then it's not a Qt problem. Compare with a 'native' java-App to see if this is the case.
Check if you implemented everything correctly; e.g. check if theres anything running in your main-loop or some events happenening repeatedly which consumes CPU time
And some more general advice:
Downscale your images to the appropriate view-size before giving them to the UI, as they might have to be re-scaled on every frame-update and/or consume graphics memory otherwise. E.g. dont set the source to a 1024x1024 image when it's going to show in a 64x64 view
Remove transparency from the images if they are going to display on solid-colored background anyway.
Dont overlay the images with other widgets/controls
If you're still getting a 'slow' UI, maybe try to merge all or multiple images and their surrounding UI/Controls into one or more bigger images
Very long views are not user-friendly. Maybe implement a pager or tab-view etc. to divide your list into multiple views. This way you can also decrease load-time
Dont try to implement an interface in openGL yourself. It's unlikely you'll make a better one than you already get with QtWidgets and QtQuick.
Related
I'm developing a small video editor to make quick edits to a multiple audio track video, using Qt. I'm a bit confused about whether it is possible or not to handle multiple audio tracks in payback and processing in Qt.
What I want to do with the video
list audio tracks
for each track, manage its volume, and choose to perform channel duplication on a mono track (to make it stereo).
play the video with the setting I chose for audio tracks, eventually being able to change settings on the fly.
extract a part of the video with the settings I chose.
I'm not sure if Qt can handle this by itself, or if I need to rely on a library specialized in video processing. Therefore, my question is double
If it is possible in Qt-only : how ?
I suppose I need to use QMediaPlayer class, but it doesn't look like it can handle multiple tracks at once.
Maybe by splitting the media into several sub-media, but then how to synchronize their playback?
Otherwise : external library. Are there any caveats to avoid?
I wonder what is the best way, if there is one, to display video frames (assuming audio will be handled by external lib)?
Should I draw frames directly on a QWidget, or should I use OpenGL directly? Or another method?
Note: I'm not forcibly looking for a detailed answer, I'm fine with short ones and/or external resources.
After a bit of searching around, I found that it is impossible to do in with Qt as for now.
I found several libraries able to fulfill such purpose (list is non exhaustive for sure) :
libvlc, which was able to render easily on a QWidget surface, but at the time I looked, was not able to play multiple channels at a time. Next version should be able to do it tho.
libffmpeg and libav, which are a bit too low-level for what I want, and which I found fairly complicated to use to render on a QWidget surface.
libopenshot, which has quite a difficult learning curve, and not that much documentation unfortunately, as it is oriented toward nonlinear video editing.
libgstreamer. The one I chose.
I found libgstreamer to be the best for my purpose, being fairly high level, and well documented. It also is flexible to use, as it allows loading from and dumping to any kind of file automatically.
It is able to render directly on a QWidget surface, which is super convenient.
On the other hand, it has an async and dynamic design which requires a bit more planning and error management, but documentation is there to help.
So far I didn't encountered any major problem so far, I'll update this post if something new comes up.
I would like to have a tool to debug 2D planar meshes. I would like to be able to display them and debug to be able to debug certain things.
Is there a widget (for any toolkit on Linux - QT, GTK+Cairo, ...) which would display the images, scroll them and zoom it. Is there any widget which would handle it (without need to implement zooming, scrolling etc. by hand)?
Side requirements:
Needs to work on CentOS 6
I need it for C++. Unfortunately changing the build system in my situation is harder then it sounds.
The Qt Graphics View is certainly a useful tool, it gives you scrolling, zooming, rotating easily. You probably want to learn the basics of Qt before. (and Qt is in C++).
Here's an off the wall suggestion.
This would be fairly easy to implement in a web browser. Web browser engines already have the base functionality for resizing and scrolling over images. You may need a little JavaScript to bind it together, of course.
So why not use WebKit? There are bindings for many of the leading toolkits (e.g. QWebView for Qt), so you could take your pick of which one you're most comfortable with.
Yes, it's overkill. But it's code you don't have to write, and time is money.
I am working on a touch screen application (WinRT) and currently draw some graphics to the screen. Because it is touch, I want to enable pinch-to-zoom for scaling the entire content. For a better experience, I only want to redraw the graphics, once the pinch gesture is complete. For the intermediate scalings, I would like to reuse the current bitmap, and perform (if possible) a gpu-only scaling (enlarge bitmap).
Basically, I want to do exactly what iOS and Windows Phone have been doing for years now.
How can I implement this in Direct2D?
As a bonus, If you know a good ressource for reading on Direct2D, please tell me. The MSDN documentation is really poor and I have to hunt different blogs and magazine articles to learn :(
What I tried so far:
m_target->SetTransform(
D2D1::Matrix3x2F::Scale(
D2D1::Size(1.5f, 1.5f),
D2D1::Point2F(500.0f, 500.0f))
);
However, if I do this for interactive elements (like page zoom-in/zoom-out), all objects are rendered (which is also slow).
Another option could be to draw into a BITMAP and use that as the base for the transforms. However, I am not sure if this is a good approach.
Note: I am currently debugging on a Desktop but want to target tablets. I have to consider that tablets are orders of magnitude slower. That's why I try to optimize this functionality.
Thanks!
Could anyone suggest me a particular way to implement animation in my Dialog-based mfc program? The animation that I am intending to add is like a construction digger machine graphic that would read the values of the machine parameters and change the shape of the graphic accordingly. Most of the information is read from a text file in terms of the parameters, so I just need to be able to get the animation working.
Thanks for your help in advance.
Well, GDI is easy but ugly and quite slow, GDI+ is also easy, but nicer although generally slower. OpenGL or DirectX are much, much faster but quite hard to program. Other libraries, such as cairo, are also available.
I'd suggest to start with the easiest (maybe GDI+) and see if it is fast enough for you.
Do do that, just Invalidate() the control where you are drawing in a timer, (or when you receive new data), and paint the whole graphic in the OnPaint() function. A basic improvement is to Invalidate() only the region where the new data affects the picture.
If then you notice that your code is not fast enough, come back and ask how to improve it. A concrete example will make it easier to get a more useful answer.
there are lot of articles. Most of them based on drawing in device context
http://www.codeproject.com/KB/GDI/flickerfree.aspx
http://www.codeguru.com/cpp/g-m/bitmap/article.php/c4879
http://www.codersource.net/mfc/mfc-gdi-plus/animation-control-mfc.aspx
I have an application that I want add some cool animations to show state changes. However, wxwidgets would be difficult because I'd have to program these animations in straight gdi. What's the best way to add these effect windows? Should I open a flash window and run a flash sequence or is maybe some other technology? Does .net have something I could code into a dll and run from my wxwidgets binary? I need something that is super easy to draw and set up the animation.
It's hard to say what the best approach would be to achieve "cool effects", but in most cases you would want a double-buffered drawing surface. That's what I've used in similar-sounding situations.
In wxWidgets, you would want wxBufferedDC.
You could prepare animation as a bunch of images (wxImage loaded from PNG, GIF, JPG or whatever files), and then use a timer and paint them on a control. Maybe it sounds like too much, you I believe you could do it in 50-70 lines of code.
Perhaps you just could make a single widget that has a custom paint-event that hand-draws the various widgets inside it? Then you could draw them at the appropriate locations/sizes without having to involve wxwidgets at all, it would just be a bunch of line-draw/rectangle-draw/text-draw commands to update the display for each frame of animation.