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. is the code is a bug?
Forum Updated to NodeBB v4.3 + New Features

is the code is a bug?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 201 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.
  • nicker playerN Offline
    nicker playerN Offline
    nicker player
    wrote on last edited by
    #1

    I made a class named STableItem which inherited from the QTableWidgetItem.
    the STableItem class set the checked mode .
    and after I set the STableItem class into the QTableWidget,I put the instance of the STableItem into an qlist,which like this:

    class STableItem :public QTableWidgetItem{
    QJsonObject var_data;
    void doAction();
    }
    STableItem * titem = new STableItem ();
    QList<STableItem *> mlist;
    QTableWidget table;
    table.setItem(0,0,titem);
    mlist.push_back(titem);

    after that I changed the text by using
    mlist.at(0).doAction();
    but the var_data of the titem occured the errors.so what should i do to get the real item and call the method of the instance?

    jsulmJ 1 Reply Last reply
    0
    • nicker playerN nicker player

      I made a class named STableItem which inherited from the QTableWidgetItem.
      the STableItem class set the checked mode .
      and after I set the STableItem class into the QTableWidget,I put the instance of the STableItem into an qlist,which like this:

      class STableItem :public QTableWidgetItem{
      QJsonObject var_data;
      void doAction();
      }
      STableItem * titem = new STableItem ();
      QList<STableItem *> mlist;
      QTableWidget table;
      table.setItem(0,0,titem);
      mlist.push_back(titem);

      after that I changed the text by using
      mlist.at(0).doAction();
      but the var_data of the titem occured the errors.so what should i do to get the real item and call the method of the instance?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @nicker-player Please format your code properly!
      Please post the error you get!

      Where is this:

      QTableWidget table;
      

      If it is in a method/function - what do you think what its lifespan is?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      3

      • Login

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