How to implement a VS-like window manager (floating tabs) with Qt? - c++

I'm developing on a project that needs an interface with support of floating tabs similar to the ones in Visual Studio (as is shown below).
The interface is expected to provide the following features:
Several sub-windows are in the main window and can be added, removed or moved to another place;
When several sub-windows occupy the same space, they appear as several tabs;
Users can drag & drop the sub-windows (tabs) to move them to another place;
As the sub-windows are dragged beside one of the sides of the main window, they can be automatically docked to the side;
When a sub-window (tab) is not docked to any of the sides, it appears as a standalone window and can be located out of the range of the main window (to support multiple monitors).
So how can I implement such a VS-like window manager (if it is called so)? I am familiar with C++ and Qt and plan to implement such features with Qt.
I've tried two of the choices Qt provides to me, but both in vain:
I tried building a MDI application with Qt. I tried the official MDI example and found some problems:
The sub-windows are not automatically docked;
The sub-windows are not turning to tabs when they occupy the same space;
The sub-windows cannot be located out of the range of the main window.
I also tried using the dock widgets (mainly QDockWidget). I tried the official dock widgets example and also found some problems:
The central widget is useless, but once it is removed (programmatically, with answer in this question) the auto-docking feature seems broken;
The sub-windows can only be docked to one of the sides. For example, I cannot create 4x4 sub-windows in a main window.
So how can I implement such features with Qt and C++? Is there a handy solution provided by Qt, or do I have to implement these manually (by listening to the mouse events and set the correpsonding sub-windows)?
Thanks in advance!

I think I have had the answer.
The answer is: there's no easy way to do this with pure Qt. And QDockWidget is nearest to the perfect solution. If you would like to implement such features, you have to do so by yourself.
However, fortunately, there are implementations of such features by others, which can be found by searching through the Web. For example, by searching through GitHub, I have found 2 repositories that contain implementations of such features:
mfreiholz/Qt-Advanced-Docking-System
JackyDing/QtFlex5 (works on windows platform with DWM on only, according to its README)

Related

How to align the button in Gtkmm?

I am using Ubuntu OS.
I am new to GTKMM GUI building application.
I am following the tutorials which they have on their websites.
https://developer.gnome.org/gtkmm-tutorial/stable/sec-helloworld.html.en
I can resize the window with helloworld.set_default_size(500,500);
but I cannot move the position of button("hello world").
It is always aligned at center.
I tried with m_button.set_alignment(0.0,0.0) but nothing seems to be working.
Why it is that much difficult to move button to any position.?
kindly suggest some solution if available.
If you want to place a widget like a button, you have to use some container widget like Gtk::Boxor Gtk::Grid. Inside such container widgets you can place you child widget as you like, but typically not directly per point position.
The container widgets use some internal logic to order and resize the contained widgets.
From the documentation:
Many GUI toolkits require you to precisely place widgets in a window, using absolute positioning, often using a visual editor. This leads to several problems: ...
gtkmm uses the packing system to solve these problems.
You can find the full documentation here:
Multi-item widgets
I did not know if there is a container widget which allows direct positioning by giving a point position. If someone has an additional hint, let us know!
Sometimes automatic is better than manual handling, but sometimes it is not :-)

Colorizing the titlebar in macOS with multiple colors

I have a Qt app that runs on macOS. I found a way to change the color of the titlebar here, however I want to take it a step further. I want to mimic the titlebar that the Slack and Discord apps use. For example:
As you can see, the color of the controls in the window extend to the very top of the app's window. I figure there are two ways to accomplish what I want:
I can build on the code pasted above. Looking through some of the Apple developer documentation, I think I can create a couple NsWindows on top of the titlebar with whatever width I want and attach the titlebar as a parent for those windows. Once I do that I should be able to make the same backgroundColor() color call for each one. Of course, this will require me to keep track of when the controls or window are resized and adjust the NsWindows of the titlebar, and I am not sure what (if any) issues that could cause.
Maybe there is a way to essentially set the height of the titlebar to 0? I wonder if that's what the Discord app is doing because:
if you look closely, the edit box that says "Find or start a conversation" is vertically lined with the close, minimize and maximize buttons, as is the "Activity" label. But if the controls do extend to the top of the app's window then how are the standard app buttons getting painted?
I'd be curious to know how Slack and Discord accomplish this even though I know they're not using Qt.
I realize there is not a Qt solution since Qt does not paint the titlebar. I know this will be OS-specific, but since I do not have any real experience with Objective-C++ or working with Cocoa (all of my programming experience on macOS has been standard C++ with non-UI or Qt-based code) I'd appreciate any suggestions or guidance!
Natively this is done with fullSizeContentView and titlebarAppearsTransparent properties of NSWindow. Once you set them to true, you can draw or place controls beneath the title bar.

With MFC, how to style a CEdit control with rounded corners and shadow?

I would like to provide highly styled form elements for a client within an MFC application.
I am coming to the conclusion that 'Web-2.0'-style widgets are simply not possible in the MFC universe without major custom painting/programming work.
I include screenshots to compare:
A desired 'Web 2.0'-style edit widget, and
the 'best' edit widgets
straightforwardly available in the MFC universe.
Example A: Here is a screenshot of a (randomly chosen) nicely styled edit widget that is easily available and trivial to use in the web programming world with HTML/CSS:
Example B: In contrast, here is a screenshot taken from one of BCGSoft's MFC library's example applications. This very example application is titled "Edit Box Demo", and provides - it seems - the best edit widgets available in the MFC universe:
You can see that there is a 'generation of difference' between easily-available HTML edit widgets, and the seemingly best-available MFC/C++ widgets for Windows desktop applications.
My question is therefore straightforward: How is it possible to style a CEdit control with rounded corners and shadow in MFC?
Just pointing you to Example B you used
Using CBCGPEdit it should be simple and straight forward to overwrite OnNcPaint.
But! Usually you can instruct the BCG to use a visual manager and in this case the visual manager will be responsible to draw the controls frame. And the visual manager will use round corners if it is designed to do so... I know even no visual manager that uses round corners ;) (CBCGPVisualManager::OnDrawControlBorder)
But feel free to write your own.

How to create a GUI without a frame in X11?

I'm trying to figure out how to create a graphical interface, in X11, which exists outside of a window manager's/desktop environment's standard window frame. For example, when Thunderbird finds new mail, it shows a special alert in the lower right hand corner of the screen which is shown without any frame (no close/minimize buttons, etc.).
I'm specifically interested in doing this in QT with C++, but if someone knows a solution with a different graphical library, that would be helpful too.
For QT pass Qt::FramelessWindowHint as a window flag when you construct your top level widget.
See here for more info:
http://doc.qt.nokia.com/main-snapshot/qt.html#WindowType-enum
You can do this with X as well although I haven't done so in a long time.
http://www.xfree86.org/current/XCreateWindow.3.html
With GTK you would use gtk_window_set_decorated(), which would probably be Gtk::Widget->set_decorated() (I think, I don't use gtkmm).
http://developer.gnome.org/gtkmm/unstable/classGtk_1_1Window.html#a67adb1d8051a38e0e5272f141bb8778c

Divide the application screen in Qt

I want to divide the application screen into parts like one part is fixed showing fixed controls & another one is variable which can be changed when user select something. Like in Qt Creator we are having the left side column always fixed & the content of center screen is changing when user is selecting something. I have attached the screen shot. How to do it. if any one is having any idea please help me.
When you speak of the Qt Creator you certainly mean the controls on the left and right. In my opinion, the best thing to implement that are QDockWidgets. Have a look at them in the docs and as Martin said, look at the examples, they are perfect to learn each of the layout and composing issues.
QDockWidgets can be made floatable (undock them from the main window as toolboxes), they can have fixed sides to be docked on and it's easy to use them, because they can be filled with every widget you like. I often use them when I show a file explorer in an application, for example. Just look at the examples and play with it.
If you just want to have QActions visible all the time for the user, you can use a QToolBar.
You normally start with a QMainWindow and then put other toolbars, controls, widgets etc inside that.
Check out the Qt examples that come with the SDK src