Application viewer setfullscreen function not hiding ubuntu sidebar - qt

I'm building the UI for an application using Qt and QML for Ubuntu Linux. I have a viewer window with a canvas element which is supposed to be fullscreen by default. On opening the application this works fine (i.e. Ubuntu sidebar and top taskbar are hidden). However, once I minimize my application and then maximize it again by using viewer->setFullScreen();, the Ubuntu sidebar and top taskbar are still visible and there is an offset while writing on the canvas due to the same.
Any help would be appreciated.

According to this topic on askubuntu, your problem do really looks like Unity bug (or feature). But, according to somehow related bug on Launchpad, it seems that you can get desired behavior by:
Turn "Always On Top" on via right-clicking the titlebar of your window, before making it go fullscreen.
This will prevent the Unity panel from rendering on top of this fullscreen-window, when using the other screen.
In Qt you can set Qt::WindowStaysOnTopHint to your window/widget via QWidget::windowFlags.
Pay additional attention to notes in official documentation:
This function calls setParent() when changing the flags for a window, causing the widget to be hidden. You must call show() to make the widget visible again.
About Qt::WindowStaysOnTopHint -- Informs the window system that the window should stay on top of all other windows. Note that on some window managers on X11 you also have to pass Qt::X11BypassWindowManagerHint for this flag to work correctly.
Hope this helps.

Related

How to make the top QWidget modal?

I'm developing an application in PyQT5 which has a QWidget object on the top. This application needs to be able to run in 'kiosk' mode, so my aim is to make that top QWidget modal and prevent any other running application of being focused.
The skeleton of the main class is below. Note that I'm calling the setWindowModality() method which in theory sets the behavior of the window to the chosen one:
class MyApp(QWidget):
def __init__(self):
QWidget.__init__(self)
self.setWindowModality(3)
My main method is the following:
app = QApplication(sys.argv)
MyApp()
sys.exit(app.exec_())
As per the setWindowModality() method documentation:
Qt.NonModal 0 The window is not modal and does not block input to other windows.
Qt.WindowModal 1 The window is modal to a single window
hierarchy and blocks input to its parent window, all grandparent
windows, and all siblings of its parent and grandparent windows.
Qt.ApplicationModal 2 The window is modal to the application and
blocks input to all windows.
The problem is that the window is not modal at all, I can switch to a different application (say a Web browser), which is exactly what I want to prevent. I've also tried 1, 2, 3 as values and they produce the same behavior.
I'm afraid this could be a design restriction in order to avoid apps block other apps, but I'm not sure of it and I'm unable to confirm it.
Am I missing something obvious here? In case the problem is the design restriction, is there a way to still simulate a modal window?
Modality is only with respect to current application. If application has only one open top level window, then there's no difference between application and window modal. This modality has no effect on other applications, so you are not able to achieve what you want with it, there's no simple "desktop modal" flag.
You can use Qt to make the window full screen, but you have to use other means to prevent user from accessing the desktop, or closing the app (often bound to ALT-F4 keyboard shortcut). If your platform is Windows, then I don't know how to do that, but I'm sure there's a way. Under X11 (used on Linux usually), the most straightforward way to do that is not have a desktop at all, simply by just running the app without desktop. Look up nodm package for an easy way to do this.

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.

How to make modeless dialog stay on top of its parent in Solaris CDE

I have a problem with Qt modeless dialog in Solaris 8/10 machine using CDE (Common Desktop Environment).
The dialog serve as drawing panel/popup that required user to choose the tools from main application before proceeding to draw on it. The problem is whenever user click on main application toolbar, then the dialog will goes behind the main application.
Notice that this is the behavior pertaining to CDE only, Open Windows enviroment or Solaris Java environment don't cause this issue.
My question is how can I make it always on top of its parent (main application)?
I've tried to pass in WX11BypassWM flag to the dialog, to by pass window manager, but then the border and frame is gone which cause the dialog to not drag/move-able.
Update 1:
With regard to Andy's answer:
I've tried Qt::WStyle_StaysOnTop, but it doesn't work.
I tried also to combine:
WX11BypassWM | WStyle_StaysOnTop | WStyle_Title
and other combinationa of WStyle_DialogBorder, WType_TopLevel etc, it only stays on top if WX11BypassWM is passed in.
But whenever WX11BypassWM is passed in, the dialog shown up will not have border nor the tittle bar.
Which means it's a unmove-able tittle-less dialog.
Update 2:
Since I can't find a solution for this issue, for the time being, I resolve it by resizing and reposition the main application and the modeless dialog to be side by side.
This at least will let user navigate in both interface.
Anyone if has a better suggestion then let me know.
I'm not sure I understood your question, but, wouldn't it be possible to use :
Found in QtAssistant :
enum Qt::WindowType
flags Qt::WindowFlags
Qt::WindowStaysOnTopHint :
"Informs the window system that the window should stay on top of all other windows."
I hope it helps a bit !

Flex-AIR: Make application with NO tab in taskbar?

I have an AIR app about half way done right now. I was informed by the client today that he does not want a tab to show up in his task bar. I already have this in place for new windows by making them lightweight. I do not know how to make the main window lightweight though. If there is not a way, is there a work around, like not not having a main window and just opening lightweight windows, don't know how that could be done either though? Anyone know how to do this?
Thanks!
Check this doc out. -- Yes, you can do this. In short, you have to hide the initial window - then display your application in a lightweight window.
Also - do note: On a Mac - the behavior is different. By convention, a window is not shown in the 'task bar' when it is displayed. When it is minimized it is in the bar. To hide the application when minimized on a Mac - you have to make the window 'invisible' instead of minimizing it. The doc mentioned above gives further details.
The key part of the doc for your case:
On the Windows operating system,
windows created with the types utility
or lightweight do not appear on the
taskbar. Invisible windows do not
appear on the taskbar, either.
Because the initial window is
necessarily of type, normal, in order
to create an application without any
windows appearing in the taskbar, you
must either close the inital window or
leave it invisible.
To close all
windows in your application without
terminating the application, set the
autoExit property of the
NativeApplication object to false
before closing the last window. To
simply prevent the intial window from
ever becoming visible, add
false to the
element of the
application descriptor file (and do
not set the visible property to true
or call the activate() method of the
window).
In new windows opened by the
application, set the type property of
the NativeWindowInitOption object
passed to the window constructor to
NativeWindowType.UTILITY or
NativeWindowType.LIGHTWEIGHT.

how to keep a nativewindow on top

I need to keep a NativeWindow I am creating on top of the main window of the application.
Currently I am using alwaysInFront = true, which is not limited to the windows in the application. I can successfully synchronize the minimize/restore/move/resize actions, so the top window behaves appropriately in those cases. Even though using this option has the drawback that if I alt-tab to other application the window goes on top of the other application.
Because of the above I am trying to get it to work without using the alwaysInFront. I have tried using orderInFrontOf and orderToFront, which gets it in place but when I click an area in the main window the top one becomes hidden i.e. air makes it the top one.
I have tried capturing activate/deactivate events but it only happens on the first click, so on the second click the top window becomes hidden again. I also tried making the top window active when the main one becomes active, but that causes the main one to loose focus and I can't click on anything.
Ps. I am doing this to improve the behavior of a HTMLOverlay I am using - see Flex Air HTMLLoader blank pop up window when flash content is loaded
Listening for Event.DEACTIVATE and calling event.preventDefault() should work. Not sure if that is what you have tried, but I have an app where that does the trick.
I ended up turning on/off the alwaysInFront option based on whether the main window or the top window were active i.e. if none where active I turned it off. This was additionally to what I mentioned in the question.
That way when the user switches to another application, the window doesn't go on top of the other apps. I still would prefer a solution where I don't have to use the alwaysInFront option, or even better an alternate solution to the flex loading flash in external sites issue I linked to above.
Ps. I will try to check with the owner of the HTMLOverlay to submit a patch (its an improvement, although its tied to an app that doesn't open extra windows when opening the overlay).
Update: I have committed the changes to the HTMLOverlay.
I'm trying to do something very similar. In an AIR application, I have one large full screen window which is essentially the "desktop". I always want this window to stay behind all other windows in my app. There are, however, some items on the "desktop" window that need to be clickable.
There appears to be no clean way to force a window to maintain its position in the window ordering.
What I've settled on so far, which isn't perfect, is to make all other windows in my app use the alwaysOnTop property but bind this to a global var (ugh) that I maintain to track the overall application level active/inactive state. This way, when I switch to another app, my windows don't float above the all other app windows - they correctly move behind as expected.
Then, I have a regular (alwaysOnTop=false) window that is fully transparent as an "overlay" to the desktop window on which I can place various interactive controls. This window is OK to come forward since it's transparent and my other windows are alwaysOnTop.
Finally, and crucially, I install three event listeners on the "desktop" window as follows:
protected function onApplicationComplete(event:Event):void
{
this.addEventListener(MouseEvent.MOUSE_DOWN, onClickHandler, true,1000,true);
this.addEventListener(MouseEvent.CLICK, onClickHandler, true,1000,true);
this.nativeWindow.addEventListener(Event.ACTIVATE, onActivateWindow,false,-1);
}
protected function onActivateWindow(event:Event):void
{
trace("sent via activate to back");
orderInBackOf(bigTransparentWindow);
}
protected function onClickHandler(event:MouseEvent):void
{
trace("sent via click to back");
orderInBackOf(bigTransparentWindow);
}
I'm not entirely happy with all this since there is still some occasionally noticeable flicker of objects in the overlay window - it appears that the "Desktop" window gets ordered in front of it, an update of some sort happens, and then it gets forced behind again.
Any better solutions welcome!

Resources