PDA

View Full Version : How to change default windows class name?



Kevin Hoang
25th May 2010, 15:49
QT creates all windows only with one windows class name is QWidget. Can I change this to random name?

Zlatomir
25th May 2010, 16:09
I don't think that is possible, and i don't find a reason to do that, so why do you need to change the class name?

But what you can do is: derive from QWidget and give the class any name you want.

jryannel
25th May 2010, 21:45
Not sure if I understand you right. Here my 10cents ;-)

For window: QWidget::setWindowTitle(), changes the window title
For general widgets: QObject::setObjectName(), changes to object name (good for debugging)

Kevin Hoang
26th May 2010, 04:21
You haven’t understood my aim. I want to hide windows class name for spy programs. Somebody know this?

jryannel
26th May 2010, 08:18
Can you proide an example how someone spys on your program and read the QWidget (window) class names?

whitelynx
11th January 2012, 23:37
I'm actually curious about answering this question myself... I think the problem so far is that the term "class name" is ambiguous when it comes to GUI programming. The term as used by the original poster doesn't refer to the classic OOP concept of a class, but rather to a string attached to each window in many (all?) modern windowing systems. For instance, under X11, you can determine a window's class by querying its WM_CLASS property, using a program such as xprop or xwininfo:

# xprop WM_CLASS
WM_CLASS(STRING) = "urxvt", "URxvt"

On MS Windows, there are programs such as WinSpy++ which allow you to view a window's class name. (I believe there's also a more basic program called WinSpy which comes with Visual Studio, which performs the same task)

In my case, I'd like to change the class name of all message boxes in my application so that I can match them in my window manager's settings, and force them to a higher layer than another program. (I'm developing an embedded Linux-based distro for my work, so we have pretty tight control over the environment)

Edit: A small clarification: In my application, which is using Python, PySide, and Qt 4, the WM_CLASS attribute is always set to "App.py", which is the name of the main file of my application, and the value of argv[0]. I'd like to be able to change that for individual windows in my app.