Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. How to remove a flag?
Forum Updated to NodeBB v4.3 + New Features

How to remove a flag?

Scheduled Pinned Locked Moved Unsolved Qt for Python
4 Posts 3 Posters 4.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.
  • D Offline
    D Offline
    deleted485
    wrote on last edited by
    #1

    Hello,
    i am new to Qt or PyQt and have a very basic question.
    I have a Table Widget Item and I set a flag to it.

    table.item(0, 1).setFlags(Qt.ItemIsEnabled)
    

    Now the user can't interact with the cell of the table anymore.
    But now i want to remove this flag and allow the user to interact with the cell again. How do i do that?
    Thank you

    JonBJ 1 Reply Last reply
    0
    • D deleted485

      Hello,
      i am new to Qt or PyQt and have a very basic question.
      I have a Table Widget Item and I set a flag to it.

      table.item(0, 1).setFlags(Qt.ItemIsEnabled)
      

      Now the user can't interact with the cell of the table anymore.
      But now i want to remove this flag and allow the user to interact with the cell again. How do i do that?
      Thank you

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by JonB
      #2

      @Moesen
      You can write this in Python as you would in C++:

      table.item(0, 1).setFlags(table.item(0, 1).flags() & ~Qt.ItemIsEnabled)
      

      As in C++, use | to "OR in" a flag and & ~ to "AND out" a flag. https://wiki.python.org/moin/BitwiseOperators

      BTW, really you should have written table.item(0, 1).setFlags(table.item(0, 1).flags() | Qt.ItemIsEnabled). The way you did it with setFlags(Qt.ItemIsEnabled) will clear any other flags which might be set, whereas really you only want to set the enabled flag on top of whatever else might or might not already be there.

      1 Reply Last reply
      4
      • D Offline
        D Offline
        deleted485
        wrote on last edited by
        #3

        Thank you, this helped me so much!

        F 1 Reply Last reply
        0
        • D deleted485

          Thank you, this helped me so much!

          F Offline
          F Offline
          fzminwl
          wrote on last edited by
          #4

          @Moesen Please mark the thread as resolved!

          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