I have a MyComboBox class, inherited from QComboBox, in order to override the method focusOutEvent:
- mycombobox.h
class MyComboBox : public QComboBox { public: MyComboBox(); protected: void focusOutEvent(QFocusEvent * e) override; };
- mycombobox.cpp
#include "mycombobox.h" MyComboBox::MyComboBox() { } void MyComboBox::focusOutEvent(QFocusEvent * e) { // I will code here qDebug()<<"Object has lost focus"; MyComboBox::focusOutEvent(e); }
But I don't know how to declare a comboBox as object of MyComboBox class, and having a incompatible type between MyComboBox and QComboBox with this on MainWindow constructor:
MyComboBox* oMyComboBox;
oMyComboBox = ui->comboBox;