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. How to impliment signal and slot when click on checkbox in first row of the QTreeWidgetitem
Forum Updated to NodeBB v4.3 + New Features

How to impliment signal and slot when click on checkbox in first row of the QTreeWidgetitem

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 929 Views 2 Watching
  • 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by Qt Enthusiast
    #1

    I have following code and I want to impliment signal and slot

    int main(int argc, char **argv)
    {
    QApplication app(argc, argv);
    QTreeWidget table;
    table.setColumnCount(3);

    QTreeWidgetItem* item = new QTreeWidgetItem();
    item->setFlags(item->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable);
    item->setText(0,QString::number(0));
    item->setText(1,QString::number(1));
    item->setText(2,QString::number(2));

    item->setCheckState(1,Qt::Checked);
    item->setCheckState(2,Qt::Checked);

    table.addTopLevelItem(item);

    table.show();
    return app.exec();
    }

    K 1 Reply Last reply
    0
    • Q Qt Enthusiast

      I have following code and I want to impliment signal and slot

      int main(int argc, char **argv)
      {
      QApplication app(argc, argv);
      QTreeWidget table;
      table.setColumnCount(3);

      QTreeWidgetItem* item = new QTreeWidgetItem();
      item->setFlags(item->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable);
      item->setText(0,QString::number(0));
      item->setText(1,QString::number(1));
      item->setText(2,QString::number(2));

      item->setCheckState(1,Qt::Checked);
      item->setCheckState(2,Qt::Checked);

      table.addTopLevelItem(item);

      table.show();
      return app.exec();
      }

      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      @Qt-Enthusiast

      You can't simply implement something in main and expect to get it to work with signal and slots. You need a class which inherits from QObject in order to benefit from signal slot mechanism.

      I suggest that you are examining the examples e.g. http://doc.qt.io/qt-5/qtwidgets-itemviews-editabletreemodel-example.html
      There you have a good start for some experiments. Using the debugger will help you to understand some more details about the functionality.

      Vote the answer(s) that helped you to solve your issue(s)

      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