Results 1 to 2 of 2

Thread: focus events of widget children

  1. #1
    Join Date
    May 2010
    Location
    slovakia
    Posts
    47
    Thanks
    10
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Maemo/MeeGo

    Default focus events of widget children

    hi, i got common widget with textarea and calendar... currently i listen for mouse over regarding whole widget (not it's children), showing calendar when over widget, hiding when mouse it's out of widget..

    Qt Code:
    1. #include "widget.h"
    2. #include "ui_widget.h"
    3.  
    4. Widget::Widget(QWidget *parent) :
    5. QWidget(parent),
    6. ui(new Ui::Widget)
    7. {
    8. ui->setupUi(this);
    9. ui->calendarWidget->hide();
    10. }
    11.  
    12. Widget::~Widget()
    13. {
    14. delete ui;
    15. }
    16.  
    17. void Widget::changeEvent(QEvent *e)
    18. {
    19. QWidget::changeEvent(e);
    20. switch (e->type()) {
    21. case QEvent::LanguageChange:
    22. ui->retranslateUi(this);
    23. break;
    24. default:
    25. break;
    26. }
    27. }
    28.  
    29. void Widget::enterEvent(QEvent *e)
    30. {
    31. ui->calendarWidget->show();
    32. }
    33.  
    34. void Widget::leaveEvent(QEvent *e)
    35. {
    36. ui->calendarWidget->hide();
    37. }
    To copy to clipboard, switch view to plain text mode 

    but i have no clue how to listen for mouseevent if i want same functionality with focus only on textedit... that means, i wanna show calendar only when mouse is over textedit (and textedit only)...

    any help appreciated.. thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: focus events of widget children

    Have a look at QObject::installEventFilter().
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Replies: 2
    Last Post: 7th July 2010, 14:49
  2. Replies: 0
    Last Post: 15th March 2010, 06:08
  3. widget focus ---------
    By jrodway in forum Qt Programming
    Replies: 11
    Last Post: 27th April 2009, 09:16
  4. Replies: 2
    Last Post: 19th August 2008, 09:46
  5. Mouse events without focus
    By latte in forum Qt Programming
    Replies: 1
    Last Post: 6th February 2007, 12:36

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.