Results 1 to 6 of 6

Thread: keyboard left and right arrows in qt 3.3.5

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: keyboard left and right arrows in qt 3.3.5

    Quote Originally Posted by rajaraob View Post
    i have installed event filter .
    I can able to catch all key board events except left and right arrows .
    Could you show the code of eventFilter()?
    J-P Nurmi

  2. #2

    Default Re: keyboard left and right arrows in qt 3.3.5

    My problem is to navigate the tab headers using keyboard for QTabWidget.
    My whole code look like follows .

    Qt Code:
    1. class ABC :: QObject
    2. {
    3. Public :
    4. ABC();
    5. }
    6.  
    7. void ABC::ABC()
    8. {
    9. .......
    10. .......
    11. QTabWidget m_pMasterTab = new QTabWidget();
    12. m_pMasterTab->installEventFilter(this);//event filter
    13. }
    14. //Event filter
    15. bool ABC::eventFilter(QObject * target, QEvent * event)
    16. {
    17. int cnt = m_pMasterTab->count();
    18.  
    19. if(event->type() == QEvent::KeyPress)
    20. {
    21. QKeyEvent *k = (QKeyEvent*)event;
    22. Qt::Key keyPressed = (Qt::Key)k->key();
    23. if(keyPressed == Qt::Key_Left)
    24. {
    25. int indx = m_pMasterTab->currentPageIndex();
    26. m_pMasterTab->setCurrentPage ((indx ==0)?cnt:indx-1 ) ;
    27. }
    28. if(keyPressed == Qt::Key_Right)
    29. {
    30. int indx = m_pMasterTab->currentPageIndex();
    31. m_pMasterTab->setCurrentPage ((indx+1)%cnt ) ;
    32. }
    33.  
    34. }
    35. return QObject::eventFilter( object, event );
    36. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 22nd February 2007 at 11:03. Reason: missing [code] tags

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: keyboard left and right arrows in qt 3.3.5

    Looks like a double thread to me. And this is not related to Qt Designer either..
    J-P Nurmi

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
  •  
Qt is a trademark of The Qt Company.