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] QStandarItem clean data
Forum Update on Monday, May 27th 2025

[SOLVED] QStandarItem clean data

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 873 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.
  • guidupasG Offline
    guidupasG Offline
    guidupas
    wrote on last edited by
    #1

    Hello!

    I have a QStabdardItemModel and I need to clear the data of one cell but dont remove the row

    I am trying this but its not working

    @
    modeloLancamentosAmortizacao->data(modeloLancamentosAmortizacao->index(0,2)).clear();
    @

    this way does not work either

    @
    QStandardItem *item = modeloLancamentosAmortizacao->item(0,2);
    item->data().clear();
    @

    How can I do that?

    Thanks

    Att.
    Guilherme Cortada Dupas

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      Try the following or some variant of the following ?
      @
      QVariant dat(tr(""));
      item->setData(index,dat);

      or

      QVariant var = item.data();
      var.clear()
      var.setValue("")
      item.setData(var)@

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • guidupasG Offline
        guidupasG Offline
        guidupas
        wrote on last edited by
        #3

        Yes, it worked

        Att.
        Guilherme Cortada Dupas

        1 Reply Last reply
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          May be you can move this request to <Solved> state by editing the subject line of this question.

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          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