How to use focusInEvent method of QWidget by inheriting QTabWidget?
Hello,
I'm trying as shown below,
We already have this,
Code:
{
//Standard Class
protected:
}
{
//Standard Class
}
Now below, I'm trying to access virtual methods from QWidget, but I'm unable to do that, may be I'm missing some simple basics behind it.
Code:
{
Q_OBJECT
public:
}
{
qDebug()<<"focusInEvent";
}
{
qDebug()<<"focusOutEvent";
}
I can access virtual methods from QTabWidget but not from QWidget, please give me suggestions on what I'm mistaking here?
Or its protected, that why I'm unable to access it, is there any way to access such protected methods?
Thanks :)
Re: How to use focusInEvent method of QWidget by inheriting QTabWidget?
Hi, what happens? I would say that your code should work, although I would call QTabWidget::focusInEvent() instead of QWidget::focusInEvent(). Your code skips the QTabWidget, which might not be what you want.
Ginsengelf
Re: How to use focusInEvent method of QWidget by inheriting QTabWidget?
I don't understand the point of making these virtual protected methods public in a derived class. It isn't like you can manually call them from some other class - they are called from within Qt when focus enters or leaves the widget. If you want to implement some custom behavior for these events, then you can either derive from QTabWidget (and leave the methods protected) or use QTabWidget itself and install an event handler on the instance.
I agree with Ginsengelf - if your base class is QTabWidget, then you should be calling those event handlers and not the ones for QWidget.