Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Italian
  4. Impostare una colonna di QTableWidget come 'read only' - Python 3

Impostare una colonna di QTableWidget come 'read only' - Python 3

Scheduled Pinned Locked Moved Unsolved Italian
3 Posts 3 Posters 892 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.
  • A Offline
    A Offline
    Achab61
    wrote on last edited by
    #1

    Vorrei impostare una colonna di una QTableWidget come 'read only' : è possibile farlo con QDesigner ?
    Se non lo fosse, come potrebbe essere fatto in Python ?

    Grazie

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #2

      è possibile farlo con QDesigner ?

      Non che io sappia vedi risposta sotto di @JonB

      come potrebbe essere fatto in Python ?

      Purtroppo non conosco python ma il concetto e' iterare tra le celle di quella colonna e chiamare QTableWidgetItem::setFlags disattivando la flag Qt::ItemIsEditable (in alternativa puoi settare la flag direttamente quando aggiungi la cella alla tabella).
      In C++

      for (int i=0;i<tableWidget.rowCount();++i){
      QTableWidgetItem* item = tableWidget.item(i,colonnaReadOnly);
      item ->setFlags(item->flags() & ~Qt::ItemIsEditable);
      }
      

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      JonBJ 1 Reply Last reply
      1
      • VRoninV VRonin

        è possibile farlo con QDesigner ?

        Non che io sappia vedi risposta sotto di @JonB

        come potrebbe essere fatto in Python ?

        Purtroppo non conosco python ma il concetto e' iterare tra le celle di quella colonna e chiamare QTableWidgetItem::setFlags disattivando la flag Qt::ItemIsEditable (in alternativa puoi settare la flag direttamente quando aggiungi la cella alla tabella).
        In C++

        for (int i=0;i<tableWidget.rowCount();++i){
        QTableWidgetItem* item = tableWidget.item(i,colonnaReadOnly);
        item ->setFlags(item->flags() & ~Qt::ItemIsEditable);
        }
        
        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @VRonin said in Impostare una colonna di QTableWidget come 'read only' - Python 3:

        è possibile farlo con QDesigner ?

        Non che io sappia

        @Achab61

        Screenshot from 2022-04-08 12-28-57.png

        1 Reply Last reply
        1

        • Login

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