Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QT : get the class name of an object

I'm writing a test app that simulates key presses of another application. For every key press I have to check if the right window/form is shown. So what I do is get the pointer of the window being shown and get it's window title. However, not all the windows/forms shown window titles. So I'm thinking it would be better to get the name of the class instead. How can I get the name of the class?

QWidget *pWin = QApplication::activeWindow(); 

when I try:

pWin->className();  

to get the name of the class, I'm getting:

"error: class QWidget has no member named 'className' "

Can somebody show me the right way?

like image 330
Owen Avatar asked Nov 22 '10 03:11

Owen


1 Answers

Try using the metaobject.

pWin->metaObject()->className();   
like image 184
J-16 SDiZ Avatar answered Sep 18 '22 18:09

J-16 SDiZ