Multi Screen/Window QT QML C++ application - c++

I am new to QT Quick and QML and I am trying to build a Linux Desktop multi Window application using C++ and QT. I mean application having multiples windows like:
Slash or Welcome Screen
Main Dashboard
User Profile
Charts and Graphs
Etc. etc.
I want to have these screens as independent C++ classes and QML files for example:
Dashboard.cpp
Dashboard.qml
I am able to build QML files representing these screens but not sure how to map them to a class which will control and communicate with QML and backend. I want to have each QML file represented as C++ Class. And screen stack manager will use these classes to push and pop screens from the screen stack.
I have seen the examples provided by QT but most of the examples are single screen and not explaining how to have multiple screens and how the screen stack is maintained.

Use the Quick Controls 2 StackView control:
https://doc.qt.io/qt-5/qml-qtquick-controls2-stackview.html
This control maintains a stack of QML views where the top one is always visible and you can pop and push views with animation.

Related

To disable steam overlay

I have the following setup for the game:
launcher.exe - starts under Steam on Windows and provides some settings UI for the user.
Then launcher.exe starts actual game.exe.
Problem is that the launcher.exe is using H/W accelerated UI - uses Direct2D/DirectX.
This page https://partner.steamgames.com/doc/features/overlay states:
Your game does not need to do anything special for the overlay to
work, it automatically hooks into any game launched from Steam!
But in my case that creates problems - the overlay is created on wrong window. So launcher.exe (uses DirectX) has the overlay but window that is created by game.exe (real game, uses DirectX and/or OpenGL) is not.
And the question is: how can I modify code of my launcher.exe window to prevent Steam overlay to be created on it "automatically"?
Update, response from Valve's TS:
Sorry, there's no code in place to selectively enable or disable the
overlay between launchers and games!
The only "option" is to disable DirectX drawing in the launcher.exe. In this case their injected DLL will not create that thing. But that effectively means no GPU accelerated UI drawing under the Steam... Kind of "640kb is enough for everybody" type of design.
Ideally Steam should send some custom message to the window to ask how and where the window wants that overlay to be rendered. But apparently there is no such thing, or is it?
Just for the context, the launcher looks as this:

Multiple Documents/Views in MFC Splitter Window

I currently have an MFC SDI program that displays data in Open GL. I am trying to modify the program to display multiple data files at once using splitter windows. In other words, if there are four splitter windows, each with display a different file.
So far all the examples I have found only display one document in multiple views, but I need to display multiple documents at once.
I am starting to conclude that the problem may be because this is an SDI interface. I guess I originally thought that since I was using splitter windows that it would support multiple documents at once.
So my first question is, is the SDI interface the problem? Am I limited to just one file at a time?
If the answer is that I need to use MDI, then can I display the multiple documents in one MDI view using splitters, or do I have to still open multiple MDI windows?
Thank you
I think creating multiple MDI-child windows should be very acceptable, as they are fully functional (they can be maximized, closed or tiled). You can also post a Window->Tile command, as soon as your app enters the idle state (yields); they will fully occupy the client area. You can even get deeper and provide some customizations to your CMDIChildWnd-derived class, like disabling closing, moving or resizing, or having a shorter or custom or no title bar (you may need to customize the non-client-area message processing). Also experiment with the WS_EX_TOOLWINDOW extended window style (not sure if this works well with MDI child windows though, and you will have to test it under at least Windows 8/10 and 7).
Another solution could be initially create an MDI app with tabbed views, and customize the window accommodating the tabs so that they are not... actually tabs, just simple non-overlapping child windows (you will have to arrange them on the client area yourself). This may be preferable if the view wnidows are of "fixed" size (either a set size or determined by the document data, eg image size) and should not be resizable (by the user). The MainFrame window should then be customized too, to display scroll-bars if the area required to display all views exceeds its client area. This is a lot of work though, as you will need to modify the window classes so as to provide a functionality MFC was not originally meant to support, and dig deeply into the MFC sources.
This is an old question but for those who might want to do the same thing, MFC does support the scenario mentioned. From the Microsoft documentation:
MFC supports three common user interfaces requiring multiple views on the same document. These models are:
View objects of the same class, each in a separate MDI document frame window.
You might want to support creating a second frame window on a document. The user could choose a New Window command to open a second frame with a view of the same document and then use the two frames to view different portions of the document simultaneously. The framework supports the New Window command on the Window menu for MDI applications by duplicating the initial frame window and view attached to the document.
View objects of the same class in the same document frame window.
Splitter windows split the view space of a single document window into multiple separate views of the document. The framework creates multiple view objects from the same view class. For more information, see Splitter Windows.
View objects of different classes in a single frame window.
In this model, a variation of the splitter window, multiple views share a single frame window. The views are constructed from different classes, each view providing a different way to view the same document. For example, one view might show a word-processing document in normal mode while the other view shows it in outline mode. A splitter control allows the user to adjust the relative sizes of the views.
Microsoft MFC references
https://learn.microsoft.com/en-us/cpp/mfc/multiple-document-types-views-and-frame-windows?view=msvc-170
https://learn.microsoft.com/en-us/cpp/mfc/multiple-document-types-views-and-frame-windows?view=msvc-170#_core_splitter_windows
MFC samples
https://learn.microsoft.com/en-us/cpp/overview/visual-cpp-samples?view=msvc-170#mfc-samples
MFC splitter sample
https://github.com/microsoft/VCSamples/tree/master/VC2010Samples/MFC/general/viewex

chromium embedded detect button press

I want to use Chromium Embedded Framework as GUI of my OpenGL application.
I am using Off-screen Rendering.
How to detect when a HTML button/link is clicked on?
I tried to google this but with so generic search term there is only noise.
The General Usage wiki also doesn't contain this.
I think you should catch an event in JS code and send a message to C++ code. It can be done using a message router described here:
https://bitbucket.org/chromiumembedded/cef/wiki/GeneralUsage#markdown-header-asynchronous-javascript-bindings
It is also possible to implement a custom message router using JS integration mechanic:
https://bitbucket.org/chromiumembedded/cef/wiki/JavaScriptIntegration.md
Do you pass any UI events to CEF from your OpenGL application?
In general you shall attach OpenGL and CEF instances to the same window. You shall also override request to invalidate window's area to notify your OpenGL code that it needs to rerender window including content of that on-screen buffer.
Sequence of actions:
Window receives mouse move event.
Window passes it to your CEF instance.
If CEF determines that it needs to apply :hover state to your button then it will call window.invalidateArea(areaOfTheButton).
You handle that window.invalidateArea() by updating OpenGL scene including new version of your off-screen bitmap.
From CEF you should also receive various secondary DOM events in response to mouse move/up/down/etc. on window.
And check this: http://sciter.com/sciter-and-directx/ - it is DirectX window with integrated HTML/CSS UI with my Sciter Engine. At the moment I am designing the same but for OpenGL.

How are opengl menus that go outside of the window implemented?

I was looking at how sometimes when you right click, the menu goes outside of the window.
Is this implemented with a separate window? If so, how can I get this functionality. I am trying to use GLFW, but I understand if it isn't possible.
Currently I am on windows, but I like keeping my options open, which is why GLFW would be preferable.
I noticed that GLUT has such a feature. If you are confused to what I am looking at then look at that.
Thanks for any help!!
Overlapping menus (in MS Windows) have to be implemented as a new top-level window, you would have a new OpenGL rendering context and draw the menu in that space - yes, it's a fair bit of work all for the edge-case of a menu overspilling the parent window,
However this isn't often a problem in OpenGL programming because if you're working on a full-screen game then the menu will always be displayed within the main window, and even if it isn't a full-screen a game your users really won't notice them as games tend to use different UI concepts like radial-menus which wouldn't overspill the parent window.
Or if you're working on a non-game title, chances are it isn't full-screen and is going to be an OpenGL rendering area within a larger application that is rendered using a native UI toolkit (e.g. 3ds Max, AutoCAD, etc), in which case no problem: just use native menus.
You can, of course, use native menus in an OpenGL application anyway, provided you do the necessary plumbing for native window messages.

No maximize button on XLib window

Is it possible to create a window with only Minimize and Close button (and preferably not re-sizable) in C++ and XLib?
On my Ubuntu I can see some of these type of windows (like the System Configuration window).
I am very new in the Linux+X11 world and I want to create a small window like this. How would this be done (not asking for code but for some references to the API components that would be of use or techniques that you know)?
You need to set _NET_WM_ACTION_MINIMIZE and _NET_WM_ACTION_RESIZE as the list of allowed actions for your window