QTreeWidgetItem Disable | Enable



  • How To Disable | Enable QTreeWidgetCurrentItem?

    void wdgMyTree::PauseSLOT()
    {
        QTreeWidgetItem * last = ui->treeWidget->currentItem();
    
        if (last == top) {
            return;
        }
       
        last->setDisabled( !last->isDisabled() );
    
        if (globalall->db.open()) {
    
            QSqlQuery qry;
                      qry.prepare("update Tree Set Pause = :value where UID = : uid");
                      qry.bindValue(":uid", mpuid[last]);
                      qry.bindValue(":value", last->isDisabled() ? 1 : 0);
                      qry.exec();
    
            globalall->db.close();
        }
    }
    

    When the item is turned off and the last item changes, I will not allow you to get involved.
    I can not stand on the disabled item.



  • Use setFlags

    Qt::NoItemFlags allows nothing on the item



  • Hi. @VRonin
    Yes I use it.
    But when I disable the item and I move anothar item I can not go back To get involved.

    QTreeWidgetItem * last = ui->treeWidget->currentItem(); **!BLOCKED**
    


  • If you ant to go back you can set the Qt::ItemIsSelectable flag



  • @VRonin

        QTreeWidgetItem * last = ui->treeWidget->currentItem();
    
        if (last == top) {
            return;
        }
    
        last->setFlags(Qt::NoItemFlags);
    
        last->setFlags(Qt::ItemIsSelectable);
    
    

    it not work :X



  • Could you put down a quick bullet list with:

    • what you are doing in the GUI
    • what you expect to happen
    • what happens instead


  • @VRonin
    I Disable Item
    alt text

    I move Another Item

    alt text
    I can not enable disabled item



  • @VRonin
    I can not select disabled item, problem it is.



  • What's the difference between an enabled and disabled item? just the colour of the text? Does the behaviour change between the two?



  • @VRonin said in QTreeWidgetItem Disable | Enable:

    What's the difference between an enabled and disabled item? just the colour of the text? Does the behaviour change between the two?

    No.
    If I'm turned on or off, I'll have to decide on the following steps.



  • Then you are misusing setDisabled.



  • @VRonin
    I'm not good enough to understand your words.
    I will think of something else.

    • last->SetChecked( Qt::Checked or Qt :: Unchecked ); // bla bla bla

    • Or replace an icon.

    Just to understand the user.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.