make a borderless app without a controlbox on Qt - qt

Is it possible to make a borderless window on Qt? I know its possible in Visual Studio you just change the value in the properties window. Qt doesnt have a formborderstyle property.
Also is it possible not to display icon on taskbar

I think it is not possible to suppress the taksbar entry. Each top level window without a parent will get one.
It surely is possible to create a frameless window. I once used a plain QWidget for a similar purpose and add something like the following:
setWindowFlags(Qt::Dialog|Qt::FramelessWindowHint);

Setting the window flags using setWindowFlags() on your top level widget with
Qt::FramelessWindowHint - Draw without window frame
See the full doco at http://qt-project.org/doc/qt-4.8/qt.html#WindowType-enum and http://qt-project.org/doc/qt-4.8/qwidget.html#windowFlags-prop
As for hiding the taskbar look at this stack overflow example Qt Hide Taskbar Item (just sets the windowFlags to include Qt::Dialog you could do what your looking for with
MyWindowWidget(QWidget *parent)
: QWidget(parent, Qt::Dialog|Qt::FramelessWindowHint)

Related

QWidget with movable/draggable children

I'm looking for an existing solution in Qt5 which would allow me to construct a QWidget with horizontal layout with some child widget which would be movable within parent widget area.
As an example of such behaviour you may try to play with tabs in firefox - user can drag a tab and move it right and left and other tabs are drawing aside to make a place for dragged one.
Also I'd like to be able to drag and drop child widgets from one parent widget to another, like in case of firefox: one tab can be dragged to another window. However in my case drag and dropping would occur in one application.
Is there such a solution or I've to do it myself?
I am using Qt4 but I am sure that the following should work for Qt5 too:
For moving tabs within tabwidget there is a API "setMovable (bool movable)" available in QTabWidget class.
To your other requirement you may need to do a little bit of coding. You should look into documentation of QDrag class and
examples of drag-drop in qt installation (examples/draganddrop) folder.
Santosh

How to change QIcon color?

I am working on a custom control box (that min,max/restore/close button in the top right of your Windows titlebar) for my new application. I use closeIcon = style.standardIcon(QStyle.SP_TitleBarCloseButton) to get the correct icon for them. See the full code here in my other SO question. What I got is a black icon. In which I need the white version when it's in hover state.
Can we .. I don't know, inverse it? Or should I get another icon from QStyle?
This question (and several others) are from the intention of creating a chrome like tab in PyQt application, by hiding the titlebar and reimplementing control box. But it didn't gives the best result. Right now this is my solution to create a chrome like tab in PyQt application. Therefore, I close this question.

Window flags not helping in mdiarea in Qt

I am using Qt and creating a GUI with multiple sub windows. I am using MDI Area for the same. I want to hide the top toolbar of mdi subwindow but using window flags is not helping.
I have tried writing the code as follows. First I tried for mdiarea and then for subwindow but neither worked.
mdiarea.setWindowsFlags(Qt::FramelessWindowHint);
subwindow.setWindowsFlags(Qt::FramelessWindowHint);
I have also tried using Qt::CustomizedWindowHint but even that is not helping. Please help me with this.
Thank You.
Try this:
mdiArea->addSubWindow(new QLabel("Qt::FramelessWindowHint"), Qt::FramelessWindowHint);
You don't want to set the MDI area itself as a frameless window, because it's a widget you likely have embedded in another window... it most likely already doesn't have a frame.
Your setting the 'subwindow' should work... but addSubWindow(myWidget) actually wraps the widget passed in in the real subwindow, so that's what was going wrong. Qt lets you pass in window flags as the second parameter of addSubWindow() and those flags go to the real subwindow.
Note that with a frameless window, you can't drag the window around to move it, or grab the edges to resize it, because there's nothing for you to grab onto!
If you just want the minimize and maximize buttons gone (but still want the close button), try passing Qt::Dialog instead.
Try also experimenting with these:
addSubWindow(new QLabel("Qt::Tool"), Qt::Tool);
addSubWindow(new QLabel("Qt::Tool|Qt::CustomizeWindowHint"), Qt::Tool|Qt::CustomizeWindowHint);
addSubWindow(new QLabel("Qt::Dialog"), Qt::Dialog);
I think Qt::Tool|Qt::CustomizeWindowHint is probably the best option (no buttons, but still movable and resizable - if you don't want it resizable, give it a fixed size (setFixedSize()).
Edit: Also try: Qt::CustomizeWindowHint|Qt::WindowTitleHint

How to have detachable tool windows in Qt

I am developing a tool which will have some variable sized windows. I am able to achieve this using the QSplitter horizontal & vertical. Please see attached image.
Now, how to make these individual windows detachable/maximize/close? How can I add cross markers at the top-right-corner of each window so that they can be closed maximized or detached from there? Just like this link :--
http://vector.com/portal/medien/ecu_testing/tae/test_automation_editor.png
You're looking for the QDockWidget class:
The QDockWidget class provides a widget that can be docked inside a
QMainWindow or floated as a top-level window on the desktop.
QDockWidget provides the concept of dock widgets, also know as tool
palettes or utility windows. Dock windows are secondary windows placed
in the dock widget area around the central widget in a QMainWindow.
Check out this example
In 2021, there is KDQDockWidget, an apparently much better Qt docking framework with both commercial and open source licenses.
The site lists the following advantages:
It provides advanced docking that QDockWidgets doesn’t support.
The layouting engine honors min/max size constraints and some size policies.
Supports PySide2 bindings.
Clean codebase.
Supports lazy separator resize.
You can reorder tabs with the mouse.
Supports partial layout save/restore, affecting only a chosen sub-set.
Allows double clicking on title bar to maximize.
Allows double clicking on separator to distribute equally.
Shows close button on tabs.
Allows you to make a dock widget non-closable and/or non-dockable.
Provides an optional maximize button on the title bar.
FloatingWindows can be utility windows or full native.

Prevent Subwindow Resize

:D
I'm a Qt beginner and I have some problems.
Generally, all the languages and tools that have an GUI builder have for the window the "Resizeable" property.
Very well, I need to do the same in Qt:
No window resize, no resize pointer in hover the window's border, maximize button (in the window's title) disabled.
I'm tried to find something but unsuccessfully.
If someone help me, I'll be grateful.
Hug.
Sorry for my english. I'm brazilian. :)
In Qt Creator, I think you can create a non-resizable window by giving it the same minimum and maximum size.
Or you can do it by code using setFixedSize. In that case, just add this line in your window's constructor:
setFixedSize(size());
Use void QWidget::setWindowFlags ( Qt::WindowFlags type ). see enum Qt::WindowType for the list of flags you can play with.
For instance, setting Qt::Dialog | Qt::FramelessWindowHint should produce a windows without resize frame and no max/min button.

Resources