Opening Qt window from QML - c++

I have created a C++ Qt class, inheriting from QWidget. I have also created a QML file, which runs as my main, and I want in some point of the program to open another separated window containing this widget.
The point is to draw line graphs in QML, and I don't quite understand how to do it.

First of all, take a look at this question and its answers: Qt5. Embed QWidget object in QML
You got into XY-problem. You do not need to embed QWidget to your QtQuick/QML application. (I hope) You can easily deal with your task using only QML. For example, there is Canvas Element that can help you to organize drawing. Take a look at tutorial related to Canvas in QmlBook.
Hope this helps!

Related

Can we create a graph in QLabel? If not, what's the best way to create graphs in a dialog box?

I need to create a graph in my dialog box which displays as I've shown in the image. I need some guidance to move forward with this. Example graph is shown here
So I am developing an application in Qt creator, and I need to display a graph in a dialog box that would give better understanding of different stores and comparisons among them.
Firstly I need some guidance to know what type of Qt widget should be used and then how to create those blocks as a graph.
I am not that familiar with qt grasp, can someone help me out with this?
Qt's designated widget to render images is indeed QLabel. Just render your graph, load it up on a QPixmap by calling for example QPixmap::fromImage, and then update your QLabel by calling QLabel::setPixmap.

Qt Widget inside qt3d window

How to put a label or button into qt3d window? Is it possible? Havent seen any example... I was trying to simply put qt3d in windowcontainer, assign layout to it and layout->addWiget() but it just doesnt work.
I know this is a farily old question but I wanted to give a more detailed answer if anyone else stumbles across this.
I implemented a Qt3D widget which you can find here. Unfortunately it relies on a method to obtain the texture id from QAbstractTexture which is only available from Qt >= 5.13 so that's the minimum version you have to use.
createWindowContainer draws the respective window above everything else. So you'll never be able to draw any buttons inside the container.
You can of course have buttons and everything else around your containered 3D window. But that's specifically not what you wanted.
You can use Dear ImGui - and it's Qt3D integration. ImGui is used to draw GUI elements using vertices in 3D environments.
Of course you can always use QML - there you should be able to place buttons inside the 3D view.
you have both label and (radio)buttons on the first example for C++ into the QT3d documentation, refer to Qt 3D: Basic Shapes C++ Example
QExtrudedTextGeometry seems to be the class for 3D text

What Qt widgets should be used for sprite animation viewer

I'm looking to make a sprite animation editor. I have the loading of my custom animation file done but now need to get the actual ui started. I'm really just stuck on what widgets I would use to actually play my animation. I need to be able to go to certain frame, play, pause, loop, etc. Once I'm done with the viewing portion I plan on adding in the editing.
I've seen AnimatedSprite in qt docs but that seems to only allow playback of sprites in the same file. In my situation sprites can be from multiple image files and sometimes doesn't follow a grid like sprite cutter.
First of all, you should decide whether you want to use QML or Widgets. AnimatedSprite is QML related class. All widget-related classes starts with "Q" letter.
If you decide to use Qt Widgets, I would recommend to take a look at Qt Animation Framework in combination with Qt Graphics View Framework. Most likely it will not let you do everything you want out of box, but it should provide you with a rich set of useful tools.
If you need here are some examples.
Hope it helps.
Have a look at QMovie. This class may provide all the methods you need, as long as you only want to use it for viewing. The QMovie can be passed to a QLabel to show the animation.
QMovie however supports only gif out of the box (and there is a third party plugin for apng files). You would probably have to create your own image handle plugin to support your format.
If thats not applicable or to complicated, you will most likely have to create your own custom widget. Have a look at the painter example. Playing an animation is not that hard if you have all the frames. A simple QTimer to change the image to be drawn in a constant rate should work.

Making Qt Widgets Stretch and Scale w/ Main Window

I'm wondering if there is a way to make Qt widgets within a QMainWindow widget stretch and scale as the size of the main window is stretched and shrunk. Basically, I'd like the entire window and it's contents to have the same appearance except for size:
At the only way I can think to accomplish this is to get the size of the main window, do the math for every single widget, and reset their sizes any time the main window size is changed, but I'm thinking there's an easier way.
I like this video tutorial on youtube. I'll help you create a layout using QLayout classes. If you use QtCreator/Designer, you can also take a look at the auto-generated ui_MainWindow.XXX file that will clue you in on how it uses some of the UI classes.
As always, QtCreator/Designer has a bunch of hints and tips so you should be able to dig up from the documentation that's embedded in the application.

Adding Menu bar to QT cvNameWIndow

I am trying to create video-player application with open CV using QT creator. using openCV it is possible to play video files by adding each video frame as an image on an instance of cvNamedWindow.
Now I would like to add a menu bar to this cvNamedWindow so that I can add File, help etc menus. menus. I looked up the documentation of cvNamedWindow and I couldn't find any clue. Any suggestions?
P.s. In opencv windows created using QMainWindow, it is straightforwaed to add menu bar. But what I want is to add the menu bar to cvNamedWindow not to a window created using QMainWindow.
OpenCV's user interface is quite limited, so there's no way to accomplish what you are looking for with OpenCV's API.
On the other hand, Qt has a rich API for building graphic applications. Luckily for you, I just shared cvVideo: an example that demonstrates how to play videos on a QWidget surface. Plus, the demo has some neat tricks to change aspect ratio modes. Almost forgot, it displays a simple QMenuBar too.
you can use createButton and createTrackbar with namedWindow, but that's it.
sure, you could simulate a menu with a row of buttons, but if you need something more advanced,
stick to the native Qt api.