Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    [Solved] Make QTableWidget cells Read Only?

    General and Desktop
    3
    4
    17895
    Loading More Posts
    • 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_coding
      CAD_coding last edited by

      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 Reply Quote 1
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 1
        • CAD_coding
          CAD_coding last edited by

          Thank You SGaist!
          That works fine :)

          1 Reply Last reply Reply Quote 0
          • F
            fatinbrain last edited by

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

            1 Reply Last reply Reply Quote 0
            • First post
              Last post