draw a line on c++ using qtcreator - c++

I am extremely new on both c++ and qtcreator. At school I asked for draw a line between 2 crossed corner of an image. I am planning to use the Bresenhams Algorithm to calculate the line however I don`t know anything about the graphics library.
Can you tell me how to put a dot to a point which calculated by the algorithm?

Your question is too vague. qtcreator is just a GUI for QT development, there is graphic library in QT that should be used for your purposes, but anyway, you should gain some level in c++/qt (i.e. not to be an "extremely new") to successfully utilize it.

Related

Alternative for qt 3d and opengl in qt

My situation
I want to build a cross platform application, with a gui, that displays a 3d view of some simple cubes, that the user can interact with. Qt seemed like a good tool for the job and I think I have the gui part sufficiently down for the most part. For the 3d part OpenGl or the qt/3d implementation seemed like the right tool, but it does not work. When I try to run the examples from Qt, that use a 3d view, they are unstable, they crash, show a black window and on the offchance, that I find one, that does work there is aggressive flickering and my entire system becomes unresponsive when I only try to resize it. I don't know what is wrong, I don't think I can do a better job, than the official examples and I don't think, that trying to debug the examples is the way to go. (If someone has an idea how to fix this tell me, but I don't even have an error message)
My question:
Is there a simple framework, that would allow me to display simple 3d shapes and include that in a Qt application. I don't need shadows, or reflections or transparency or anything more fancy, than ambient light. Just some solid coloured boxes I can rotate and click on. I think it would even be fine, if it ran on CPU rather than GPU. It would be nice, if I could keep using C++, but if it only exists in another language, what gives. I don't really want to build a framework from scratch. How could I include such a foreign framework in Qt?
I am using ubuntu 20.04 with intel graphics, but as I said, I want the resulting application to work on as many platforms as possible.
I am working on an application that uses Qt3D with then OpenGL renderer. Deploying the app to a handful of users, I found some severe issues with Intel Integrated Graphics, ranging from crash to rendering bugs like flickering. This unfortunately doesn't comes from Qt or OpenGL itself but more from how Intel implements their OpenGL drivers.
The crash bug seems to impact older intel chips, very few references of that apart some random minecraft FAQ on reddit: https://www.reddit.com/r/Minecraft/comments/48ktct/19_faqs/
But what is claimed there seem to align with what my users are experiencing.
The flickering bug has only been reported recently and I unfortunately don't have the right hardware to replicate it yet...
I know it's like random, not sourced information but I thought that personnal experience might help.
I used osgQt many years ago. It looks active still. I know the military likes them.
https://github.com/openscenegraph/osgQt

What type of a tool should I use to make a simple simulator in C or C++

I'm a Rails/web developer with little experience with C++, so I'm not totally sure what direction to head in: I'm looking to build a simple simulator that I can use to test an algorithm I'm building that converts standard images to radial coordinates, and all I really need to be able to do is to plot points (which will represent LEDs) on a blank window and continuously refresh them (the LEDs blink). I don't want to build a gui; command line is fine, as I'll be the only person using the tool.
I'm not sure whether this is even possible or not... I did some Java programming years ago and I remember being able to pretty easily open a window and render images in it. Is there a C++ equivalent?
Thanks in advance!
What you are describing is a perfect fit for a GUI application, rather than command line, as far as I understand.
But if you want something really simple, and not spend some time learning a GUI development framework (MFC, Qt, WxWidgets, etc), you should check the following resources:
character based basic console graphics
some more advanced console graphics with blinking, box drawing, etc.
using full GDI graphics on console
It's not that easy in C++, because there is no standard way in doing this. It's not part of the language. There are a lot of frameworks though, some lightweight and some bloating. It also depends your platform. Anyhow, I think I would use OpenGL and do that calculation thing in a shader. That way you don't have to recompile and rerun all the C++ code. You can even do it in way that updates the GPU shader whenever you save your shader file giving you immediate results.

Can gnuplot draw interactive graph items?

I always assumed gnuplot just produced static jpeg (or whatever) images. Recently I downloaded and compiled this package which demonstrated that gnuplot also (at a minimum) is capable of zooming and rotating images.
My question (1) is whether it can also interactively draw lines (sorry if that is not the correct terminology) and such. For instance, if I have generated a sales or stock graph, is gnuplot capable of using the mouse to draw a trend line or similiar? (2) If it is capable of this, is it then possible to save the altered graph? (3) Can gnuplot graphs be easily incorporated into a QT GUI application?
Thanks much for any answers and references or examples.
Gnuplot 4.6 includes Qt support. There is example code in the distribution package that show how to embed the output into a simple Qt application.
It is capable of doing some of the things you described (although it may take some creativity/reliance on external programs, etc...). See the help for mouse and more importantly bind, help mouse variables, etc. And finally, embedding in a QT application is probably the most difficult ... (although I am not completely familiar with the QT framework). I'm not entirely sure that one is possible.
Sorry to get to your question so late, but I though I would answer in case someone else wants to do something similar.

What library to choose to build a user interface for a C++ software that uses SDL

I have a simulation software (C++) that runs on the command line. It is platform independent (currently compiling and running on Windows, MacOS X and Linux). When the simulation ends, I visualize the result with SDL; it is a very basic 2d view, mainly color squares next to each other.
I would like to have a user interface on top of the simulation so that I can start and pause the simulation, and change the parameters on the fly. Something pretty simple I guess. Well, ideally I will also add a grapher somewhere to see the evolution over time of some parameters.
Now, I am wondering what direction I should go.
Should I try to use one of the UI libraries for SDL ?
Or maybe wxwidget in conjunction with SDL ?
Or simply wxwidget and get rid of SDL ?
Do you have any experience with this ?
Thanks in advance
Barth
PS: I tried to use AGAR, a SDL UI library. It seemed very promising but I couldn't get it working. Not even the helloworld.
It may be worth you time to look into Qt. It is generally the most mature free Gui framework available. It is cross platform. And it has hardware accelerated rendering if your drawing needs some speed.
Here is a comparison posted on WxWidgets site.
In the end if your windowing needs are minimal you should choose the framework you are most comfortable with.
Probably using wxWidgets without SDL would be the easiest way to go. SDL is a media layer -- it's supposed to allow cross-platform media application development. As you only need graphical display, you only need wxWidgets -- and it will be a lot easier too!
You would benefit from SDL if:
you'd need very fast blitting of very large amount of surfaces (we're talking the 60fps range here)
you'd use RLE, color keying or other graphics operations
you'd use other media (sound, advanced real-time input, etc)
you'd need to run the software on embedded systems (handheld consoles, etc)
If the answer to all 4 is "no", then you won't benefit from SDL, and using wx alone will be much easier.

Game development with Qt: where to look first?

So, I'm going to develop a Pac-Man clone with Qt. The problem is that I do not really know where to start.
I quickly take a look at the documentation and some demo. I also downloaded some game sources on qt-apps.org. And it seems that there is a lot of ways to develop a game with Qt!
In your experience, which part of Qt should I consider to develop a Pac-Mac clone ?
The Animation Framework
The Graphics View Framework
The Paint System
Qt Declarative
Any help would be appreciated.
I think that QGraphicsView framework is the best way. Create a QGraphicsScene, some QGraphicsItems for the elements of the game. You have collision detection for free.
Most of KDE games are based on the QGraphicsView framework. It is a good fit for simple game development.
I'm currently working on a project providing gaming-specific Qt Quick Components for cross-platform game development, might be of interest: http://v-play.net :)
At the very minimum you will want to look at QGLWidget. You can get an OpenGL program up in a few minutes by deriving from QGLWidget, it will create the window, context, handle mouse and keyboard input, etc. Create a QTimer to trigger updateGL() every 10-15 ms or so and your good to go. I think there is a demo somewhere for setting this up, but it has been awhile since I saw it.
If you want to embed widgets into the window, I would look at QGraphicsView. There is a demo of this called boxes. Just beware the demo is a tad hard to learn from as several classes are thrown into the same file and it might take a few moments of tracing to figure out where the flow is.
Since you are doing a 2d game, you might want to look at using QPainter on top of OpenGL. This allows you to draw primitives easily instead of doing them with OpenGL calls. I never could get this to stop flickering in fullscreen though.
There's a book about game development in Qt here, it's a bit old, but it might give you some ideas. But IMHO, Qt is widget based and is a bit slow for a game, you might consider using SDL or OpenGL.
I'm developing a simulation of rigid bodies with Qt and OpenGL using the PhysX API from Nvidia. If you want to see this approach, look at my project at github: http://github.com/lucassimao/Simulacao-Estereologica
Well, one place to look could be the Gluon game development framework, which is currently under development. It depends on what you're really aiming for with your PacMan clone, but Gluon may well be what you're after: https://github.com/KDE/gluon
If anyone else is interested in learning how to make GAMES using C++ and Qt, have a look at my YouTube tutorial series. It explains the graphics view framework through a series of videos which build upon a single game that we start in tutorial 1.
C++ Qt Game Tutorial 8 - Adding Graphics
If you are not comfortable with Qt yet, then I REALLY loved VoidRealm's Qt tutorial series, also on youtube (C++ Qt 1 - Introduction to QT programming).
A good start would be:
Qt Examples And Tutorials
Perhaps if you need to cheat you may want to look here
xpacman.tar.gz