Results 1 to 6 of 6

Thread: [SOLVED] QTableWidget: column switch with tab key -- how?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2007
    Location
    Toruń, POLAND
    Posts
    24
    Thanks
    7
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default [SOLVED] QTableWidget: column switch with tab key -- how?

    Hello,

    I have persistent editor (QTextEdit) opened in each cell and now I would like to be able to just switch the column (I have 2 columns) when the user presses tab key.
    setCurrentCell(currentRow(),1-currentColumn());

    To do so, I reimplemented eventFilter in QTableWidget and I wait for tab key. There are two problems:
    1) I cannot turn off TabKeyNavigation in QTableWidget
    2) my code works and then it is ignored, like this: works, works, works, ignored, ignored, works, works, works, ignored, ignored, works...

    The result is totally bizarre -- you get 3 times column switch, then "normal" navigation twice, then column switch x3 and so on.

    I checked what event I get, and it appears I get key releases all the time, but not presses. Also, it looks like this (inside eventFilter):

    ( press, release, ) x 3, release, release, press, ...

    How can tab key be released twice in a row without pressing?

    Tab handling part of evenFilter:
    Qt Code:
    1. if (key_event->key()==Qt::Key_Tab ||
    2. key_event->key()==Qt::Key_Backtab)
    3. {
    4. if (_event->type()==QEvent::KeyPress)
    5. setCurrentCell(currentRow(),currentColumn()==1?0:1);
    6. _event->accept();
    7. return true; // event handled
    8. }
    To copy to clipboard, switch view to plain text mode 

    Thank you in advance for enlightening me :-)

    have a nice day, bye
    Last edited by macias; 12th August 2007 at 12:07. Reason: solved

Similar Threads

  1. QTableWidget stretch a column other than the last one
    By roleroz in forum Qt Programming
    Replies: 6
    Last Post: 4th February 2015, 06:35
  2. QTableWidget first column always visible
    By topino in forum Qt Programming
    Replies: 13
    Last Post: 30th December 2014, 08:06
  3. changing column width of QTableWidget
    By juliarg in forum Newbie
    Replies: 4
    Last Post: 22nd March 2007, 15:51
  4. Replies: 6
    Last Post: 13th October 2006, 14:40
  5. QTableWidget column and row sizes
    By Arthur in forum Qt Programming
    Replies: 4
    Last Post: 27th January 2006, 11:03

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.