I have a problem.
I have 2 QTextEdit
fields : value & name.
When I push the button i create QTableWidgetItem
s with the value from "value" and "name".
But now I will check if the name alredy exists.
But I don't know, with " findItems " ? with contain's ?
Tabelle extends from QWidget
in the header.
I'am an c++/ QT Beginner and have no idea as I do that such.
PS: I'am speaking Germany, so you can answer in Germany, my English isn't very good ;D Thank you :)
void Tabelle::pushButtonClicked() :
strname = ( txtname ->text ());
strvalue = ( txtvalue ->text ());
The textfields to Strings.
Put the vlaue in Items:
QTableWidgetItem * valueitem = new QTableWidgetItem(0);
valueitem->setText(strvalue);
QTableWidgetItem * nameitem = new QTableWidgetItem(0);
nameitem->setText(strname);
New row :
if ( cou >coucount )
{table->insertRow(table->rowCount());}
table->setItem( cou,1, valueitem );
table->setItem( cou, 0, nameitem); cou++
You can use QList QTableWidget::findItems(const QString & text, Qt::MatchFlags flags) const.
As the doc says: Finds items that matches the text using the given flags.
Try the following code:
QList<QTableWidgetItem *> ItemList = Table->findItems("TestName", Qt::MatchExactly);
cout<< "Count:" << ItemList.count() << endl;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.