Results 1 to 6 of 6

Thread: keyboard left and right arrows in qt 3.3.5

  1. #1

    Default keyboard left and right arrows in qt 3.3.5

    hi ,
    i am using QTabWidget for my application . I want to use left and right arrows to navigate around tabs . I am using qt 3.3.4

    please let me know which property on QTabWidget be given.

    Thanks in advance for your help .

    regards
    raja rao

  2. #2
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: keyboard left and right arrows in qt 3.3.5

    You could install an event filter that catches the key presses for the keys that you are interested in. The you can move between the tabs programatically depending on the keys.

  3. #3

    Default Re: keyboard left and right arrows in qt 3.3.5

    Thanks for you response.
    i have installed event filter for QTabWidget object .

    I can able to catch all key board events except left and right arrows .

    Left arrow, right arrow and other keys are working fine for QLineEdit installedEventFilters(..).

    Is there any reason why QTabWidget installedEventFilters(...) are not capturing left and right arrow key board events or is it a bug ?

    I am using qt 3.3.5 and windows xp OS .

    And please do provide me url for known issues in 3.3.5 for installEventFilters(..) if any.

    Regards
    Raja Rao
    Last edited by rajaraob; 22nd February 2007 at 09:48.

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

    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

  5. #5

    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

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

    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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.