in Qt, How do I make a window be the current window? - qt

My QT app has multiple windows and sometimes, even though the windows are already open but burried under other windows, the user will select an option to open one from the mainwindow menubar in which case I want to simply bring it up and make it the current one. Now using QWidget->raise makes this window go on top of all other windows but it doesnt select it and that is what I need to do. I tried QWidget->setFocus but that doesnt do anything. In the mean time I am using a combination of QWidget->close followed by QWidget->show but I would like to know if there is a command to use with ->raise.
I tried:
pMission->raise();
pMission->setFocus(Qt::ActiveWindowFocusReason);
but it didnt work so i used:
pMission->close();
pMission->show();

Have you ever tried QWidget::activateWindow?
From help file, this function is going to
Sets the top-level widget containing this widget to be the active window.
An active window is a visible top-level window that has the keyboard input focus.

On MacOS Lion with Qt 4.8.0, raise() was the only one that worked for me. activateWindow() and setFocus() did not.
(I don't have enough karma to make this a comment on Mason's answer)

Related

Keep QDialog on top of everything, even fullscreen applications?

On a project I work on, using Python3 + PySide, I try to print a popup-message as some sort of notification.
This popup needs to be on top of everything, this includes fullscreen applications like games or browsers. And that's the point that does not work. It works fine for all windows on my Desktop, normal windows, maximized, but as soon as there is a fullscreen application or a borderless window ("pseudo fullscreen") the popup is created, but "behind" the fullscreen app.
I already use self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint) but this flag does get ignored by other fullscreen apps.
How do I fix this? Also without giving focus to the popup.
It is just there to present information, and it is not good when your window looses focus while playing a game.
My code can be found here: https://github.com/GosuSan/PyECM
additional Info:
- my project aims to be cross-platform, so I need a platform-independend solution
- I am running linux, without having a windows machine atm,
so I can't test stuff there.
If you need any more info, let me know!
Edit:
It seems that PySide.QtGui.QSystemTrayIcon.showMessage does what I want, it works on fullscreen as well as on borderless-windows. So I will try to either find out how those messages are displayed on top, or just use them, not sure for now.

Can't re-open project files sidebar anymore in Atom Editor

Sorry if this is the wrong place to answer but I found no other community which could help me with this. I accidentally closed the left-sidebar that shows the currently open project and it's files. Not sure what it's called, maybe navigation, folder view, either way, I tried pressing nearly every key combination to no results. I tried searching in the command palette for something that looked like "open project sidebar" but nothing. Now I'm stuck having no idea how to restore my primary navigation means when working with Atom. I tried opening multiple projects but I just get a black screen without the project sidebar, like it was hidden.
Any ideas?
I'm talking about this sidebar:
It is called "Tree-View".
You should be able to enable it via command pallete or ctrl + ,
It depends on your OS. On Mac OS X, it's CMD-\ (Command-Backslash) to toggle it. The option located on the View menu, called Toggle Tree View (the last menu option).

Build photo editor interface using Qt

I would like to create an application using Qt (PyQt5 specifically) that has a photo editor like interface. More specifically, I would like it to have:
No main window
Free-floating toolbar
Free-floating context window
Startup dialog
Edit-windows
The idea is to have the toolbar and context window persist for as along as the application is running. The user then opens one or multiple documents (e.g. images in the photo editor example) and uses the options in the toolbar to modify the document(s).
My first question is; does this type of application interface have a specific name, something akin to MDI or SDI? I've been searching for "photo editor interface" and variations on that, but haven't been able to find a search string that seems to hit the mark. For instance, I've tried "build a photo editor type interface with Qt" but it doesn't yield anything useful.
The second question I have is, what is the best way to build a Qt application that doesn't spawn a main window? It seems like I could kludge an assortment of dialogs together to make this happen, but I would really like to use a lot of the functionality of QMainWindow (toolbars, menus, top-level management of the application). Is there a way to launch QMainWindow, display the menu and toolbar, but suppress the main window?
I plan to primarily use this application on OSX, but would also like it to perform well on Windows and Linux.
QMenuBar has explicit support for OSX to have the menu bar behave as expected: http://doc.qt.io/qt-5/qmenubar.html#qmenubar-on-os-x
I think it'll also work on Ubuntu's Unity, which tries to have similar style, but there may be some details you need to take care of. Other desktops should work as expected.
As to how to have individual windows: any Qt widget will be a top level window if it has no parent, so that is an easy way to create windows. If you want to have parent windows (for example to control window stacking order automatically), there's a window flag for that. So you don't need to use QDialog (not sure if you were implying that in your question).
You want to read QWidget documentation carefully to get an idea how all this works.

WatchKit Menu Items Not Displaying

I'm in Xcode 6.2 Beta 3 (Build 6C101), I've added a menu and two menu items to my Interface Controller, and created IBActions for both. I've given them titles and images, but when I run the app nothing displays.
I've read
https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/WatchKitProgrammingGuide/Menus.html
and can't see anything about need to show menu items programatically - what am I missing?
You do not need to present the menu programmatically. The only thing you need to do is wire each button to IBActions in your Watch app extension.
The most likely issue is caching of the previous Watch app storyboard. Do a clean build and try again.
Finally, as you likely know WatchKit menus only display on a "force press". They cannot be used for the main interface of the Watch app. In the Simulator, a click and hold with the mouse will simulate a force press, and the animation will make it clear when you have done one, even in contexts where it doesn't do anything.
This was solution for me- Go to Hardware->Touch Pressure->Deep Press then try tap on watch simulator.
I have recently encountered this issue on a real device, although the menu was working as expected on the watch simulator. In my case, the problem was in SF Symbol that I've used as an image.
Everything was fixed after replacing it with an image from the assets catalogue.

Qt Creator adds an invisible character in Fake Vim mode when it loses the focus

As you may know you can activate Fake Vim mode in Qt Creator with Alt+V, Alt+v. But when I activate it in my Fedora machine, I see kind of strange behaviour. Every thing is OK but when I switch to another program or even when I open a new window in creator ( I mean when editor loses the focus ) a new invisible character is added to my editor and I can't compile the source code anymore! You can see this situation in the picture bellow. Is it kind of bug? When I delete that character every thing becomes normal.

Resources