// in the window constructorQCodeSelector *codeSelector = new QCodeSelector();QTreeWidgetItem *group = codeSelector->addItem("Group", "sample group");codeSelector->addItem("A1", "item A1", group);codeSelector->addItem("A2", "item A2", group);codeSelector->addItem("A3", "item A3", group);this->layout()->addWidget(codeSelector);// in the Ok buttonQSqlQuery qry( QString("select * from t1 where code in (%1)").arg(codeSelector->getQuotedCodes()) );