I want to do a simple Qt window with some buttons for user interaction and have a 3D scene inside this window and through this buttons, the user will configure and run the OpenCV software to analyze the image and take some decisions.
I already have the Qt software part running and my doubts are now with respect to OpenGL.
As far as I had read, Qt own implementation of OpenGL (QGLWidget) is not a full implementation of OpenGL, but more like a OpenGL ES 2.0 for increased cross platform support. I don't want to lose any OpenGL functionality since this is an exercise for future projects so is it possible to use full OpenGL and still have it shown inside Qt? And will I be able to provide this 3D scene to OpenCV as a camera?
Related
I am working on OpenGL to create a GUI .I want to create some tabs which will help me to display different things in different windows. How is this possible using OpenGL? I read in some articles that we can use QT for that. Since I have already developed some of the GUI part in OpenGL using GLUT library ,is it possible to use the same code in QT? If so brief me how to make settings for OpenGL libraries in QT creator.
In my GUI I am trying to create a Car which is following a track.
I think you might be mixing some things up: OpenGL is a API with which you can instruct drivers to draw visual primitives, like lines, boxes, 3D triangles, pictures from buffer onto a render plane.
GLUT is a library that gives you a minimal environment around that, ie. it handles creating a window etc.
Neither of them are high-level UI description tools. Qt is really most likely what you want, as it will not only give you things like tab widgets etc, but also a feature-rich framework to do things like defining what should happen when you click a button, close a window etc.
There's a lot of examples of OpenGL usage within Qt widgets. In fact, a lot of visualization frontends use Qt and OpenGL. Qt has extensive documentation on how to generate OpenGL contextes and draw inside Qt applications.
I have an wizard application written in C++/MFC that I want to improve the UI. Different buttons, change the dialog background color, etc. Could I use QT to improve the appearance or should I change to WPF and C#?
Qt 5 gives you essentially five (5!) UI toolkits:
The Gui module that is similar to what you got with a very good 2D graphics library in the late 1980s/early 1990s. You have access to the buffer of the window and to key/mouse events. Everything else is up to you. This would be the fastest way to port an existing application from "back then". The graphical primitives are neat, with fonts, painter paths, gradients, etc. but there's no notion of a widget, only of a top-level window. You draw everything where you want it to be within that window.
The provided concepts are at a higher level of abstraction than typical platform toolkits like winapi or xlib. In terms of graphical primitives it is more akin in spirit to Cairo or PDF.
It is possible to parallelize the painting of a QRasterWindow in the same way as it is done for QWidget.
The Widgets module gives you Qt4-style widgets and layouts, with customize-able styles. This is the model perhaps most like MFC, although it has much more functionality. The widgets are so-called alien widgets - it means they don't have native window handles. This keeps things fast. You have a multitude of pre-written widgets to do user input/output of all kinds. It is possible to parallelize the painting of a widget..
The Declarative module, a.k.a. Qt Quick 1, uses the QGraphicsView widget from the widgets module to display a graphical scene. This scene is described using QML. The controls are fairly rudimentary and there's no platform-specific styling. It will look all the same no matter where you run it. There is good support for animations/fluidity in the interface.
The Quick module, a.k.a. Qt Quick 2, uses a new OpenGL ES-based scene graph and can run on top of either a widget from the widgets module, or a raw window from the gui module. The scene is described using QML. There is a desktop components set that gives you platform-styled controls like combo boxes, text inputs, tables, etc. The new scene graph can really leverage the hardware and will outperform both widgets and Qt Quick 1 when you have heavy animated UIs. This is the way to go for the future. Qt 5.2 brings in an entirely new Javascript engine and a new scene graph renderer, with even better performance. Qt 5.11 brings in a new Javascript engine again, twice as fast.
The 3D module, exposed both via C++ and QML APIs, is a high-level 3D object and scene rendering system, tailored for interactive applications. It makes it easy to implement user interaction with 3D objects. The C++ and QML APIs are peers and can be used per your preference - this is in contrast to Qt Quick, where the only the QML API offers the full functionality.
Both Qt Quick 1 and Qt Quick 2 can wrap existing widgets at very modest performance cost, but you do lose out on some of the niceties of "native" QML objects.
Do note that there's a separation between the need for an OpenGL implementation and there being one provided on your system. On post-Windows-XP systems (Vista, 7, 8, etc.) you should normally use Qt 5 with its own ANGLE implementation of OpenGL ES 2 that runs on top of DirectX. Only on Windows XP you're forced to use the system OpenGL drivers.
Qt is a generally very nice framework to work with even for non-gui applications. It has good cross-platform abstractions of networking and file I/O, time/date, and provides a bunch of other general-purpose goodies. It is relatively easy to use it alongside ncurses, for example.
The fastest way to port existing MFC code would be to stay with C++ and use Qt with the qtwinmigrate solution. The latter is a BSD-licensed shim layer that can get you up and running very quickly.
I want to create an application which basically captures a webcam feed and applies a custom shader effect on it, for Windows. I could use GLSL, HLSL, any shader language really.
I've tried to use Qt, which has some very nice examples with QML and Qt Mobility, but unfortunately, it doesn't capture my webcam at all! And I didn't really find any solution to my problem. I'm using Windows 7 64-bit.
So my question is: what tools should I use to build a simple app for this quickly? languages, APIs, any tip is kindly welcome!
I would use OpenCV to capture the image from the WebCam and D3D or OpenGL to create a texture form the captured image. Here is an example.
Afterwards, I would draw a full-screen quad with the texture where you can apply your shader effects.
OpenCV can be easily built with CMake or you can download a prebuild version.
I'm writing right now an application in Python (PyQt / PySide), which should visualise and should give the possibility to edit complex dataflow graphs (like nodes in blender). Additional I want these nodes to display opengl 3D objects (small opengl scenes, like buttons on nodes), images, controls etc.
The GUI will be complex also - it will allow to subdivide to panels and allow in each panel to open a context (like in Eclipse or Visual Studio).
I'm learning QtQuick 2.0 right now and I've read Overview of painting in Qt 5. I'm wondering what are the real benefits of using QtQuick over QPainter.
QtQucik 2.0 no longer uses QGraphicsView as its backend (it uses directly the OpenGL context)
In each technology you can use OpenGL. In each you can draw custom looking buttons and widgets (like nodes, their connections etc) (you can draw them even with QPainter and handle mouse by yourself).
Of course the qml is declarative and can optimize the OpenGL calls, but does it really matter? I've been searching very long for any benchamrks between QPainter (QGraphicsView) and QtQuick 2.0 but found nothing interesting.
So the questions are:
Is really QtQuick the technology "of the future"? Should I use it if it is possible? Will I benefit from it in the future? Or it is simple "another" way of doing the same things like with QPainter with QGraphicsView and QWidgets?
Are the possibilities of QtQuick 2.0 really higher than the PySide / PyQt?
Is the QtQuick more suitable to develop this kind of application or should I stick to PySide / PyQT and QPainter?
The OpenGL mostly matters if you want to embed the UI directly with other OpenGL elements, and especially when you want smooth transitions, animations etc. on limited hardware.
1), 2) are hard to answer - it depends. For a desktop application with complex eclipse-like UI doing everything in QtQuick isn't really feasible. I'd stay with widgets there. Reimplementing Eclipse in QtQuick would be a huge task and would end up in a hardly usable UI that doesn't blend in well with the desktop. If you want animated, custom UI, then I'd go QtQuick. There it's the right tool for the job and mimicking it in QWidget/plain QGraphicsView would be pain.
A1. QtQuick is a modern technology to implementing fluidly advanced UI. It uses Scene Graph as backend which is newest technology to utilising Hardware Acceleration in a high performance and very intelligent approach. Scene Graph has best performance between QPainter, QGraphicsView, Scene Graph if target machine is OpenGL ES 2 capable.
It is very productive but you need to be care about some performance tips to keep performance as high as possible.
It is naturally suitable for MVC/MVC-like patterns but choosing/designing an efficient and suitable model to integrating and interaction between Model/Controller/View needs experience).
A2. Your question is wrong! QtQuick is part of Qt not a new thing parallel to whole Qt.
A3. In my experience, in case of a big and complex applications, you need to be careful about choosing a good approach to integrating C++ and QML (in other words controlling UI from C++).
Also you can create custom elements using QPainter or QGraphicView or QOpenGL or QQuickItem and integrate it with QtQuick based UI.
Keep in mind that static build of QtQuick is not possible now! (AFAIK)
Last word, I suggest you strongly to learn and test it in real world. Because it grows rapidly in Qt Framework and it is the future in my opinion.
I'm currently trying to get Qt working with my existing program.
I'm using SFML for creating my OpenGL rendering context and creating the window. The things I tried out so far however always create a separate window by Qt instead of just rendering into the existing context.
Is there any way I can force Qt to render to an already existing OpenGL context?
I've not looked into the specifics, but this has been done for openage.
I think looking at the documentation for QQuickRenderControl might be a good place to start.
Qt wants full control over the windows and the event loop, so this will not work (unless you put a lot of effort into it). Your best bet is using a QGLWidget and emulate the event management of SFML with that, so that your application effectively runs on Qt. It is very well possible to render Qt widgets into a OpenGL window (Qt has a OpenGL widget backend) but this must be still managed by Qt itself.