Results 1 to 8 of 8

Thread: Selection of cell with QWidget in QTableWidget

  1. #1
    Join Date
    Feb 2007
    Location
    Russia, Novosibirsk
    Posts
    11
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Selection of cell with QWidget in QTableWidget

    Situation:
    - create QTableWidget
    - all cells could be selected by mouse clicking
    - place a QWidget to a cell
    - click the cell - and it is not selected!
    To select such cells I have to catch mouse clicking event, and make some manipulations with selection model....
    May be there is more simple way? Or it is Qt-bug?

  2. #2
    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: Selection of cell with QWidget in QTableWidget

    Quote Originally Posted by Tamara View Post
    To select such cells I have to catch mouse clicking event, and make some manipulations with selection model....
    May be there is more simple way? Or it is Qt-bug?
    No, it's not a bug but the desired behavior. The cell widget is a separate widget on top of the view and receives events belonging to it.

    Disclaimer: Using cell/item/index widgets for the item views is in many cases a bad idea and should not be abused. Having too many (child) widgets is expensive in general. With item views, maintaining their geometries is also somewhat expensive, depending on the complexity of the view.

    Anyway, what does the cell widget do? Maybe you could use a custom delegate (+ editors) instead of permanent cell widgets?
    J-P Nurmi

  3. #3
    Join Date
    Nov 2006
    Location
    Russian Federation, Novosibirsk
    Posts
    7
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Selection of cell with QWidget in QTableWidget

    Quote Originally Posted by jpn View Post
    Anyway, what does the cell widget do? Maybe you could use a custom delegate (+ editors) instead of permanent cell widgets?
    How to display Rich text in cells?
    How to display simple text with small interactive area: hyperlink or info button?

  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: Selection of cell with QWidget in QTableWidget

    Quote Originally Posted by Tonal View Post
    How to display Rich text in cells?
    Use a custom delegate. See for example this post.

    Quote Originally Posted by Tonal View Post
    How to display simple text with small interactive area: hyperlink or info button?
    Use a custom delegate. Catch the required mouse press/release events and such via QAbstractItemDelegate::editorEvent().
    J-P Nurmi

  5. #5
    Join Date
    Nov 2006
    Location
    Russian Federation, Novosibirsk
    Posts
    7
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Selection of cell with QWidget in QTableWidget

    Quote Originally Posted by jpn View Post
    Use a custom delegate. Catch the required mouse press/release events and such via QAbstractItemDelegate::editorEvent().
    No.
    How to highlight interactive area with mouse hover?

  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: Selection of cell with QWidget in QTableWidget

    Quote Originally Posted by Tonal View Post
    No.
    How to highlight interactive area with mouse hover?
    You'll get mouse move events too if mouse tracking is enabled on the view.
    J-P Nurmi

  7. #7
    Join Date
    Nov 2006
    Location
    Russian Federation, Novosibirsk
    Posts
    7
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Selection of cell with QWidget in QTableWidget

    Quote Originally Posted by jpn View Post
    You'll get mouse move events too if mouse tracking is enabled on the view.
    And emulate enterEvent leaveEvent for cells and interactive areas...
    Maybe simplify insert QLabel in cell?
    But if insert QLabel selection model do not work.

  8. #8
    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: Selection of cell with QWidget in QTableWidget

    Quote Originally Posted by Tonal View Post
    And emulate enterEvent leaveEvent for cells and interactive areas...
    Maybe simplify insert QLabel in cell?
    But if insert QLabel selection model do not work.
    Sure it might simplify many things to use separate widgets. But the point was that the program will end up being a resource hog when the amount of cell/item/index widgets is high. Originally in Qt 4.0 there was no such thing as cell/item/index widgets. I guess the feature was added because so many people demanded it. The more I see these problems the more I'm convinced one should rarely use them. It's a feature which makes it easy for people to shoot themselves in the foot.
    J-P Nurmi

Similar Threads

  1. repaint a cell or row in QTableWidget
    By alphaqt in forum Newbie
    Replies: 6
    Last Post: 26th June 2012, 11:21
  2. Center a widget in a cell on a QTableWidget
    By roleroz in forum Qt Programming
    Replies: 16
    Last Post: 5th March 2009, 14:47
  3. QTableWidget (resizing rows, turning off selection, etc.)
    By kiss-o-matic in forum Qt Programming
    Replies: 6
    Last Post: 11th January 2007, 01:57
  4. Replies: 3
    Last Post: 8th September 2006, 18:54
  5. QTableWidget Sorting Multiple Selection
    By rhiacasta in forum Qt Programming
    Replies: 1
    Last Post: 30th August 2006, 21:05

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.