Is it possible in QML to add button to the window system menu? - qt

I want to add button to the window main panel (where there are a buttons close-resize-move window).
Please dont propose to draw all window by myself (without using window class).
Is it possible in qml somehow, maybe redefine window slass or draw menu bar over the window menu? Any ideas are wellcome!

I don't think that is possible since the window bar is a native thing and not rendered in the qml flow. There are some flags on qwindow that allow you to modify them a bit but thats as far as it goes. I would suggest digging into your OS-specific API (you didn't specify wich os) to see if it can be done.

Related

Popup Windows in Qt

I am very new to programming and Qt so please be patient with my ignorance. I have spent two days searching for an answer and I can't figure out where to start.
I'm using Qt 4.8.5 and I would like to create a program that has a mainwindow with a few icons that will open frameless sub windows when clicked.
I've played with the window flags example but none of the options seem to meet my needs... the popup widget is close but I don't want the sub window to disappear when I click on something in the main window. All the other widgets like window and dialog cause the mainwindow to lose focus (not sure this is the right terminology).
Is there a way to make a popup window stay open until the icon is pressed again or use another kind of widget but keep focus on the main window?
I'm sorry if this question is poorly worded.
If I understand correctly what you are asking, you could use setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint); on the widget you wish to use as a popup window. It will give you an always on top frameless window.

how to get a "lightbox" like behaviour in Qt

I have a Qt project where I'm using QGraphicsView framework, also I have popup windows on the scenes. (QDialogs)
When someone clicks on a certain button a popup window appears, and I'm invoking it with the .exec() method instead of .show() to make it the active one. Also I want to give it a visual effect like lightbox provides for html pages, so it would be obvious for the user too, that the background window won't communicate. Do you know any simple solution to make it work? or is it hard to implement in Qt?
EDIT: I don't know if it's obvious of not, but it's a desktop application, not a web application.
Just create QFrame over necessary area with customized background and transparency. For animation effect you may use QPropertyAnimation + QGraphicEffects and other stuff from qt animation framework.
Now I found another way to accomplish what I wanted. Like this:
QWidget* mytranswidget = new QWidget(mybgwidget);
mytranswidget->setStyleSheet( "background:transparent; background-color:rgba(0,0,0‌​,95)");
mytranswidget->setWindowFlag(Qt::FramelessWindowHint);
mytranswidget->setGeometry(mybgwidget->rect());
mytranswidget->show();
I'm doing it at the beginning of my popup widget's constructor so it's being drawn before draw my popup, so it will be shown in the right order.

Qt / How can I have subwindows without losing the main window focus?

I have a main window (on MS Windows) and I want to have sub windows or subpanels with free screen movement. I can use dialog and Qt::splashscreen flag, but when I am on these subwindows I lose the focus caption for the main window. Is there any trick to do what I want? (Something like a multi-focus...)
Maybe it is impossible?
I'm not sure what you mean by losing the focus.
When I create an application with multiple windows, this is what I do: in the sub-window widget, I set the parent to the main window, and set the Qt::Tool flag. It has multiple effects: the window manager sees it as one window, and when you focus any window, all the windows raise.
Do you want QMdiArea? Or a focus proxy?
In Qt, all top-level windows are independent, none is the "main". If you want to nominate one as a main window and have it steal focus from the others, then you will have to implement that manually.
Sounds like you just want to have widgets that you can move around freely on a parent widget/window, without invoking the "window focus changed" event between native Windows windows (...).
I'm not sure if there is a ready-made solution for that, but adding some grab/move/resize events to a widget's edges shouldn't be that hard, or?
I'd simply catch mousedown/up events on certain areas (these should probably be widgets of their own with a link to the parent movable widget), and have them resize/move the window when the mouse moves.

Showing when a button has been pushed in Qt

I'm using Qt with C++, and I want to make a button that keeps looking pushed down after it is pushed and released. I'm currently making buttons on a QToolBar and doing something like toolBar->addAction (icon, tr("Text"));. This makes buttons on the toolbar that display the QIcon named icon and display "Text" on hover-over. They also look pushed down as the user is pushing them, but stop looking pushed down when they are released (as is reasonable for most uses of buttons). I need something different, however: I would simply like the buttons to remain looking pushed down after they are released, perhaps until they are clicked again. It would be best if I could just call some function on a button or on the toolbar that could give me the capacity to control whether a button will look pushed down or not pushed down when it is displayed. That way I could just control this aspect of button appearance programmatically.
What's the easiest way to do this in Qt? I've seen fancy ways of doing it involving borders and very complicated setups, but I was wondering whether there might be an easy way to do it.
Add QPushButton to the toolbar using addWidget and then make the button checkable.

How to Remove Toolbar from QToolBox control in Qt?

How to Remove Toolbar from QToolBox in Qt?
Normal Toolbox looks like this:
I want to remove this button written with Page 1. Something like this :
I'm not sure if this makes much sense, since those buttons are needed for the functionality of the QToolBox. If you want a stack of widgets for which you can manually control if they are shown or not, then QStackedWidget provides similar functionality without displaying any elements of its own.
edit: No, as the QToolBox it doesn't come with a scrollbar. But since you 'fill' it with widgets of your own, which then are displayed with setCurrentWidget, you can use for example QScrollArea and placing your own widgets inside it.

Resources