Qt Quick vs Graphics View Framework (QGraphicsScene) - qt

I skimmed through new features of Qt5 and Qt Quick and don't really understand how it differs from the Graphics View Framework (QGraphicsScene) feature wise. It uses QML but beside that:
Can Qt Quick do something that QGraphicsScene can't? For example particle effects.
Is Qt Quick faster than QGraphicsScene? "Faster" meaning more FPS while displaying 1000 moving elements?
I am making a tower defense game and have been using QGraphicsScene and now I wonder whether I should switch to Qt Quick.

Qt5 and Qt Quick 2 should give a nice performance boost, thanks to "scene graph", which is the underlying engine and basically written from scratch for Qt Quick of Qt5, to take full advantage of OpenGL, and have high frame rate as a design goal from the start.
In addition to performance, I think it count's as a big feature, that you can describe the GUI, transitions, animations and all that, in a much nicer way with QML. There's some learning curve, writing declarative GUI code is quite different from writing more direct C++ code to do similar things, but it's totally worth it.
In Qt4, I don't think QML is going to give any peformance advantage, as I think (did not verify now) there it is written on top QGraphicsView stuff.
So, to summarize: Go for Qt5 and Qt Quick2, and Learn QML for desiging the GUI. Have game logic done in C++ for performance (tower defence games can have quite a bit of stuff happening at the extreme case).
Edit: Blog (old so may be slightly out of date in details) about why then scene graph implementation was created:
http://blog.qt.io/blog/2011/05/31/qml-scene-graph-in-master/

Related

Can QML replace OpenGL in Qt?

QML as per my knowledge does the same thing as OpenGL, right? So can I completely replace OpenGLwith QML ?
Whats the basic difference between QML and OpenGL?
When does people prefer QML over OpenGL and vice versa?
Your knowledge is incorrect, QML and OpenGL are two completely different things, the first is a declarative language the second is a graphics API.
QtQuick which uses QML usually uses OpenGL for its graphics, but that's a back-end you don't have any access to (it actually got a little more accessible in the recent releases but I expect not many people will go into tweaking that, and even if they did, it would be in C++, not QML).
There is Qt3D, which has a QML API, but it is just some basic stuff and it is high level - by no means a substitute to OpenGL which is very low level. That means it will be much easier to put some 3D models, cameras, materials and such with Qt3D, things you'd normally not do in OpenGL directly, but with an API built on top of OpenGL.

How low level the drawing requirements should be to use OpenGl than abstractions like QtOpenGl?

I am required to do some 3-D application and planning to chose some library for the same. I have previous experience with Qt-qml.
I read about OpenGl and found that it must be used basically when you one has very low level drawing requirements.
I also found that there is something called QtOpenGl.
Q1. Is QtOpenGl any less powerfull that OpenGl because it just just provide a wrapper over some OpenGl functionality? or it as good as using OpenGl with an advantage of working at higher level of abstraction ?
Q2. I also found there is something called Qt-3D and Qt-Quick3D. I ran some sample examples and found it easy to use because of my previous experience with qml.
Can someone share experience how powerful it is compared to OpenGl itself?
My basic question is how low the drawing requirements should be that I should use OpenGl rather than some higher abstraction like QtOpenGl ?
Q1: The Qt OpenGL module is not exactly a wrapper aroung OpenGL. It is a wrapper around GLX, WGL, or AGL. You can anyway render with QPainter using the Qt OpenGL engine. Look to the documentation to see if it is sufficiently low for you. Only 2D anyway.
Q2: Qt3D will be part of Qt5 as far as I know. It depends on what you want to do. If you want to implement 3D games it is probably quite risky. Only you know if it is sufficient for your needs.

Intermediate tutorial for OpenGL as implemented in Qt

I am making an interface for a free-and-open project I'm working on. I know that eventually I'll need it to do some heavy lifting with 3D graphics, so I'll need access to the GPU. I stumbled upon the Qt framework and its use of OpenGL. Their cross-platform properties are very appealing to me, and I've learned a lot about building run of the mill / plumbing kinda stuff on Qt, but using OpenGL is more challenging than I'd have hoped.
I've rooted around in several books and on Google for good tutorials, but they jump around, or don't seem to quite work when I try to implement them. The examples presented in the IDE have a lot of bells and whistles, and almost none of it is explained. When I tried implementing the example from "C++ GUI Programming with Qt 4", it didn't compile properly. There are a set of somewhat famous "NeHe" tutorials on OpenGL, but they are not implemented with Qt and the companion series on made by "The Independent Qt Tutorial" is very brief.
I would be very grateful for an example that goes very slowly and introduces Qt and OpenGL together. There is a blog entry that made things a lot clearer when I read it from a man named Daniel Eder. But he hasn't actually written code in that part of the discussion.
Specifically, if I could just get something really simple working in Qt like a cube I could rotate or maybe something more sophisticated like a sphere, I'd have enough traction to understand other tutorials. I definitely want to do the coding myself, but I'm having trouble even getting to the place where I can fool around, haha.
Here are some places with tutorials and examples:
There is also a Wiki in the Qt Dev network that you may find useful. I particularly suggest Wesley Stessens's blog that helped me personally a lot.
Nehe website provide a good tutorial where you can find some of the examples given ported to Qt.
There are also many QtOpenGL examples in Qt Creator/SDK that can be handy. I strongly suggest you take a look at them as they are very simple to understand and to play around with.
With that my next step was to read these two books:
C++ GUI Programming with Qt 4, 3rd edition
OpenGL Programming Guide: The Official Guide to Learning OpenGL, 7th edition
I have also been very happy when looking for help in the related Doc's/Reference manuals, etc.:
Qt Documentation
QtOpenGL module
OpenGL Documentation
At this level, you may solve your implementation problem straight away : )
Good luck.

Porting Borland C++ Builder to Qt

I have to port a project from Borland C++ Builder 5.0 under Windows XP to Qt 4.7.1 using g++ under Windows 7/mingw. The libraries and command-line utilities are done, and now I have to tackle the GUI applications, which use Borland VCL.
Can anybody recommend any tools or libraries to make this task easier?
Does anybody have any experience of this?
Edited to add: Well, I took the bull by the horns, and implemented the GUI from scratch. And I have to say, the commentators were right: I can't see any way of using the existing Borland GUI to ease the process.
There are several big differences between VCL and Qt that will make an automatic conversion process quite difficult.
Qt uses signals and slots and inheritance where VCL uses events.
VCL components use absolute coordinates and Qt uses layouts. Of course, you could use absolute coordinates also with Qt, but the GUIs would be quite awful then.
VCL's TListBox and TTreeView classes are quite different from Qt's View and Model classes (although you could use QListWidget and QTreeWidget instead).
I guess it is much faster to design totally new GUIs with Qt than to create even a mediocre VCL-to-Qt converter. And the code will be much easier to maintain. I suggest that you take one VCL form of medium complexity and recreate that with Qt. After that you can make an estimation of the total recreation work. Also you will have a better understanding about the feasibility of a conversion tool, which you most probably would need to make by yourself.
Someone has written a tool to convert dfm's to qt ui files:
http://sourceforge.net/projects/dfm2qt4ui/
Its has a few small bugs but it can save several hours of time porting form designs. In some cases redesigning specific forms is preferable - but in many cases, having labels and roughly equivalent controls positioned for you saves a lot of point-and-click action.
I agree with the current consensus that automatic conversion from VCL to QT is not a good idea because the concept behind both is very different, and you are much better off learning "the QT way" and using that from the start.
However there is one major step that nobody has yet mentioned: refactoring! Before starting, make sure you refactor the original forms to remove as much business logic as possible and leave only what is really GUI code. It depends on how good your architecture already is of course, but the VCL designer tends to encourage putting as much as possible in forms (even going as far as having invisible "data forms" with non-visual components!), so you often find a lot of stuff in the form that shouldn't be there.

Qt plotting application

Currently I'm trying to develop some simple plot prototype and I'm struggling with some kind of white/empty sheet syndrome.
I'm back to Qt after 2 years, so I feel quite retarded.
My application should:
plot and manage custom layers of data
plot on custom canvas background
manage markers on plot
My plan is to use following design:
QGraphicsScene /View/Item as a sprite like management widgets for background, markers, pointers and other "bitmap" objects etc.
QPainter/ Qpixmap or QPicture for actual data layers - and if possible set them as QGraphicItem to simplify management of dynamic graphics
I don't want to use Qwt or similar library, unless I can plot with it on custom background (I don't like the look of the qwt's graphic style).
Is my plan proper in scope of qt class usage and composition?
I'd like to have at least clear overview of the classes which should be involved for this kind of prototype.
Thanks in advance.
P.
I think you have the basic idea with QGraphicsView. Here are a few resources which might help:
Graphics View
Diagram Scene
If you want to use the new animation and state set classes:
Stickman
Also, take a look at gunnar's labs blog. He recently did a series on graphics performance.
All of these are strictly Qt (animation and state set are in 4.6). They are in C++ but hopefully you can translate what you need to python.
You don't say much about your project for me to propose a more helpful answer, but have a look at the Qt demos involving the graphics view, especially diagram scene and 40000 chips. I think you will find them inspiring for what you want to do.
May be MathGL is appropriate for you. It have Qt widget or you can use RGBA image directly to combine it with any background in your widget.
I recommend you to use QCustomPlot which is a Qt C++ library. It focuses on making good looking, publication quality 2D plots, graphs and charts and also has high performance for realtime visualization applications. You get it here: http://www.qcustomplot.com/
You may want to take a look at the Core Plot framework. Core Plot is OS X specific, but it is built on the the OS X Core Animation system which has a lot of conceptual similarity to the Qt Graphics View Framework. You'll have to learn to visually parse the Objective-C (a less-than-two day process for any competent C++ developer), but you should be able to see the general architecture relatively easily. The Core Plot wiki has some nice high-level documentation that might set you on your way without even needing to look at the code.

Resources