Results 1 to 3 of 3

Thread: How to use focusInEvent method of QWidget by inheriting QTabWidget?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2015
    Posts
    109
    Thanks
    20
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default How to use focusInEvent method of QWidget by inheriting QTabWidget?

    Hello,

    I'm trying as shown below,
    We already have this,
    Qt Code:
    1. class Q_WIDGETS_EXPORT QWidget : public QObject, public QPaintDevice
    2. {
    3. //Standard Class
    4. protected:
    5. virtual void focusInEvent(QFocusEvent *event);
    6. virtual void focusOutEvent(QFocusEvent *event);
    7. }
    8. class Q_WIDGETS_EXPORT QTabWidget : public QWidget
    9. {
    10. //Standard Class
    11. }
    To copy to clipboard, switch view to plain text mode 

    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.
    Qt Code:
    1. class MyWidget : public QTabWidget
    2. {
    3. Q_OBJECT
    4. public:
    5. virtual void focusInEvent(QFocusEvent *event);
    6. virtual void focusOutEvent(QFocusEvent *event);
    7. }
    8. void MyWidget::focusInEvent(QFocusEvent *event)
    9. {
    10. qDebug()<<"focusInEvent";
    11.  
    12. QWidget::focusInEvent(event);
    13. }
    14.  
    15. void MyWidget::focusOutEvent(QFocusEvent *event)
    16. {
    17. qDebug()<<"focusOutEvent";
    18. QWidget::focusOutEvent(event);
    19. }
    To copy to clipboard, switch view to plain text mode 

    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
    Last edited by npatil15; 10th December 2019 at 06:04.

Similar Threads

  1. QTabWidget or QWidget signals
    By mastupristi in forum Qt Programming
    Replies: 2
    Last Post: 8th November 2016, 18:30
  2. How to get the size of a QWidget in QTabWidget
    By xiangxw in forum Qt Programming
    Replies: 1
    Last Post: 4th May 2011, 01:45
  3. Replies: 3
    Last Post: 19th January 2011, 20:43
  4. Replies: 0
    Last Post: 30th March 2010, 15:49
  5. QWidget::testWFlags() - method in Qt 4?
    By Amanda in forum Qt Programming
    Replies: 1
    Last Post: 2nd November 2006, 08:08

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.