Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] Make QTableWidget cells Read Only?
QtWS25 Last Chance

[Solved] Make QTableWidget cells Read Only?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 18.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • CAD_codingC Offline
    CAD_codingC Offline
    CAD_coding
    wrote on last edited by
    #1

    Hi,
    I have a QTableWidget in my dialog.
    I have created QTableWidgetItem objects & set them as item for cells in the QTableWidget.
    I am setting the text in the items by setText() by code.
    I want to make my cells read only. I do not want the user to modify any cell in any circumstance.
    How do I do that?
    I could not find a function for this neither in QTableWidget nor in QTableWidgetItem.
    Thank You.

    1 Reply Last reply
    1
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You have to set the item "flags":http://qt-project.org/doc/qt-4.8/qtablewidgetitem.html#setFlags using "Qt::ItemFlag":http://qt-project.org/doc/qt-4.8/qt.html#ItemFlag-enum

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • CAD_codingC Offline
        CAD_codingC Offline
        CAD_coding
        wrote on last edited by
        #3

        Thank You SGaist!
        That works fine :)

        1 Reply Last reply
        0
        • F Offline
          F Offline
          fatinbrain
          wrote on last edited by
          #4

          In Qt Creator you can set NoEditTriggers in EditTriggers group of QAbstractItemVIew section

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved