views:

67

answers:

2

Hi, I'm a beginner in PyQt. I was trying to create a simple app to try some of the toolkit's many features. My question is, how can I hide the app icon from the taskbar? I don't want the user to be able to see the icon in taskbar and to minimize it using this icon. Is there any window flags that I can use to achieve this?

A: 

I wouldn't recommend trying to hide an application's taskbar presence, especially if the application is visible. If you are only trying to prevent minimizing from the taskbar then you can achieve this by creating your top level widget with the following window flags like this:

QWidget *mainWindow = new QWidget(0, Qt::CustomizeWindowHint 
    | Qt::WindowTitleHint | Qt::WindowSystemMenuHint 
    | Qt::WindowCloseButtonHint | Qt::WindowMaximizeButtonHint);

If you don't want a maximize flag, you can leave that one out of the list too.

The various window flags that Qt can use are documented here (Qt::WindowFlags).

Arnold Spence
A: 

Since I'm working with PyQt, I tried initializing the app as follows:

QtGui.QMainWindow.__init__(self, parent, Qt.Qt.CustomizeWindowHint | Qt.Qt.WindowTitleHint | Qt.Qt.WindowSystemMenuHint | Qt.Qt.WindowCloseButtonHint | Qt.Qt.WindowMaximizeButtonHint)

But this didn't prevent me from minimizing the window, or maximizing it, from the taskbar icon. What all changes should I make here?

Also I wanted to make the app work like a desktop widget. May be I'll add a sys tray icon. But I'd still like to hide the taskbar icon if possible, so that the app is visible in desktop and it doesn't distract the user with a taskbar icon.

eternalthinker
You should post follow up information/questions as comments to an answer or the original question. That way, the people already involved will get notifications. I only noticed this feedback while searching for information for another question :) Now that I know what your actual goal is, I'll see what I can find out. I'm thinking you might be able to use a secondary window for your desktop widget and hide the main window but I'm not sure how it will behave on most systems and if it will just spawn its own taskbar item.
Arnold Spence
As for that code not preventing minimizing, I can say that this sort of functionality crosses some shady system specific lines. I can only say that it worked using C++ and Windows 7.
Arnold Spence
Thanks, I will look forward to any further information from you and try out other windowflags meanwhile. I was using python in Ubuntu. The reason why I posted a new answer is that I wanted to add the code line, and it looked messed up in a comment. I suppose there's no way of formatting a comment..
eternalthinker