Results 1 to 3 of 3

Thread: how to manipulate the keyboard event?

  1. #1
    Join Date
    Jan 2008
    Posts
    39
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default how to manipulate the keyboard event?

    hi i have develop a lilttle account sistem and i need to manipulate the keyboard event, i have tryed overrriding the MyApplication::KeyPressed(Qevent * event) and configurating the TabWidget FocusPolicy to receive focus from the keyboard and the mouse, but nothiong happend!!!, can anybody help, thx

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how to manipulate the keyboard event?

    you can try to use
    Qt Code:
    1. void QWidget::focusOutEvent ( QFocusEvent * event )
    To copy to clipboard, switch view to plain text mode 
    with
    Qt Code:
    1. bool QWidget::focusNextPrevChild ( bool next )
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: how to manipulate the keyboard event?

    I think you need to handle event from QTabBar, so next example is how to do this
    Qt Code:
    1. TabWidget::TabWidget(QWidget *parent)
    2. : QTabWidget(parent)
    3. {
    4. tabBar()->installEventFilter(this);
    5. }
    6.  
    7. TabWidget::~TabWidget()
    8. {
    9. }
    10.  
    11. bool TabWidget::eventFilter(QObject *o, QEvent *event)
    12. {
    13. if (event->type() == QEvent::KeyPress && o == tabBar()) {
    14. QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
    15. if (keyEvent->key() == Qt::Key_Right) {
    16. if (currentIndex() != 2) {
    17. setCurrentIndex(2);
    18. QWidget *widget = this->widget(currentIndex());
    19. if (widget)
    20. widget->setFocus();
    21. return true;
    22. }
    23. }
    24. }
    25. return QTabWidget::eventFilter(o, event);
    26. }
    To copy to clipboard, switch view to plain text mode 
    I hope it helps you.

Similar Threads

  1. On Screen Keyboard Problem
    By cutie.monkey in forum Qt Programming
    Replies: 1
    Last Post: 16th July 2008, 13:28
  2. Qt event queue overloading?
    By gct in forum Qt Programming
    Replies: 3
    Last Post: 17th March 2008, 18:39
  3. The event fired by the mouse click on the frame
    By Placido Currò in forum Qt Programming
    Replies: 8
    Last Post: 3rd March 2007, 09:05
  4. Workload in a QThread blocks main application's event loop ?
    By 0xBulbizarre in forum Qt Programming
    Replies: 14
    Last Post: 9th April 2006, 21:55
  5. Capture a keyboard event
    By mahe2310 in forum Qt Programming
    Replies: 8
    Last Post: 16th February 2006, 11:19

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.