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]How enable editing to QTableWidgetItem?
QtWS25 Last Chance

[SOLVED]How enable editing to QTableWidgetItem?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 11.0k 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.
  • C Offline
    C Offline
    count
    wrote on last edited by
    #1

    Hi.

    I disabled editing of QTableWidgetItem via item->setFlags(Qt::ItemIsEditable^2).

    How I can enable them back?

    item->setFlags(Qt::NoItemFlags) and item->setFlags(Qt::ItemIsEditable) doesn't helps.

    Any ideas?

    Thanks.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      you should disable in a different way:

      @
      void enableEdit(QTableWidgetItem* pItem)
      {
      Qt::ItemFlags eFlags = pItem->flags();
      eFlags |= Qt::ItemIsEditable;
      pItem->setFlags(eFlags);
      }

      void disableEdit(QTableWidgetItem* pItem)
      {
      Qt::ItemFlags eFlags = pItem->flags();
      eFlags &= ~Qt::ItemIsEditable;
      pItem->setFlags(eFlags);
      }
      @

      All flags must be or'ed together, otherwise you set/remove other needed flags.
      See "QTableWidgetItem::flags":http://doc.qt.nokia.com/latest/qtablewidgetitem.html#flags and "Qt::ItemFlags":http://doc.qt.nokia.com/latest/qt.html#ItemFlag-enum

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • C Offline
        C Offline
        count
        wrote on last edited by
        #3

        Gerolf, a lot of thanks.

        I understood my mistake. Thank you very much.

        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