Results 1 to 6 of 6

Thread: QTable Widget

  1. #1
    Join Date
    Aug 2009
    Posts
    47
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded PyQt3 PyQt4
    Platforms
    Unix/X11 Symbian S60

    Unhappy QTable Widget

    Hi,


    How to set the TableWidgetItem As readonly ?

    Bye

  2. #2
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Thanks
    38
    Thanked 19 Times in 19 Posts
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: QTable Widget

    When I had to do a non editable QTableWidget I used QTableView instead.

    But maybe you can do it just setting the flag Qt::ItemIsSelectable for each QTableWidgetItem.

  3. The following user says thank you to jano_alex_es for this useful post:

    kavinsiva (23rd October 2009)

  4. #3
    Join Date
    Oct 2009
    Posts
    66
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QTable Widget

    Or this code might help

    QTableWidgetItem *newItem = new QTableWidgetItem(tr(""));
    newItem->setFlags( Qt::ItemIsEnabled );
    This flag setting will make the Table Widget item Non Editable, and the widget will be enabled.

  5. The following user says thank you to kapoorsudhish for this useful post:

    kavinsiva (23rd October 2009)

  6. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QTable Widget

    You probably want to remove the Qt::ItemIsEditable and Qt::ItemIsUserCheckable flags from the item potentially preserving the others (e.g if the item is a tristate check box or draggable).

  7. The following user says thank you to ChrisW67 for this useful post:

    kavinsiva (23rd October 2009)

  8. #5
    Join Date
    Apr 2009
    Location
    Valencia (Spain)
    Posts
    245
    Thanks
    38
    Thanked 19 Times in 19 Posts
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: QTable Widget

    But if you remove the flags Qt::ItemIsEditable and Qt::ItemIsUserCheckable the table changes it visibility... the text of each cell appears like "disabled" (gray) and it's not intuitive.

    That's why I had to use QTableView instead.

  9. The following user says thank you to jano_alex_es for this useful post:

    kavinsiva (23rd October 2009)

  10. #6
    Join Date
    Aug 2009
    Posts
    47
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded PyQt3 PyQt4
    Platforms
    Unix/X11 Symbian S60

    Default Re: QTable Widget

    Quote Originally Posted by jano_alex_es View Post
    But if you remove the flags Qt::ItemIsEditable and Qt::ItemIsUserCheckable the table changes it visibility... the text of each cell appears like "disabled" (gray) and it's not intuitive.

    That's why I had to use QTableView instead.
    Hi Thankyou to Your reply,

    I found some way to set as readonly
    Qt Code:
    1. newItem2->setFlags(newItem2->flags() & (~Qt::ItemIsEditable));
    To copy to clipboard, switch view to plain text mode 

    it set particular cell as Read only

Similar Threads

  1. QDockWidget inside another widget in the center?
    By Antebios in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2010, 07:06
  2. problem with QTable Widget
    By navi1084 in forum Qt Programming
    Replies: 1
    Last Post: 23rd September 2008, 06:09
  3. QTable Widget
    By csvivek in forum Qt Programming
    Replies: 2
    Last Post: 12th May 2008, 13:37
  4. QTable widget works slow :(
    By THRESHE in forum Qt Programming
    Replies: 3
    Last Post: 27th February 2008, 12:54

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.