Search code examples
c++qteventsmouseeventqlineedit

C++ Custom event for default controls in Qt


Is it possible to write custom event reaction and add it to default controls like QLineEdit. I have own QSplashScreen with few controls like QLabel, QLineEdit or QPushButton. For one of them I need to customize reaction for mousePressEvent. How to do that? I haven't want create new MyQLineEdit which inherit QLineEdit, I only want override default event function.


Solution

  • You can use installEventFilter() + implement eventFilter(), see the sample from Qt Docs. But instead of MainWindow there will be you custom SplashScreen.