View Full Version : Can I make a QWidget "pressable" without being a QPushButton?
alitoh
20th September 2011, 20:44
I have a topbar on my aplication and I want that, on "click" it performs a certain action. The thing is that my topbar is not a button, so I don't know how to proceed with this requirement.
My question then, is this:
Can you make it so that when you click on a QWidget it still registers said click?
stampede
20th September 2011, 21:41
Use QWidget::mousePressEvent() (http://doc.qt.nokia.com/latest/qwidget.html#mousePressEvent)
alitoh
20th September 2011, 22:08
As the object's method?
stampede
20th September 2011, 22:37
Reimplement the mousePressEvent() in the "topbar" class and do all the "click" stuff there.
Another way is to install eventFilter on the topbar button, if you don't want / can't subclass.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.