$ cat main.cpp
#include <QComboBox>
#include <QApplication>
int main(int argc, char **argv){
box.
insertItems(0,
QString("Item1, Item2").
split(", "));
box.show();
return app.exec();
}
$ cat main.cpp
#include <QComboBox>
#include <QApplication>
int main(int argc, char **argv){
QApplication app(argc, argv);
QComboBox box;
box.insertItems(0, QString("Item1, Item2").split(", "));
box.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
This works quite fine for me. Double check your code please. Call pComboBox->clear() before adding items to it, just in case. Also add qDebug() << GetStringFile() to your code to make sure the string is what you expect it to be. Adding qDebug() << GetStringFile().split(", "); might be a good idea as well. Just make sure you call the function once and then operate on the result, like this:
qDebug() << str;
qDebug() << slist;
pComboBox->clear();
pComboBox->insertItems(0, slist);
QString str = GetStringFile();
qDebug() << str;
QStringList slist = str.split(", ");
qDebug() << slist;
pComboBox->clear();
pComboBox->insertItems(0, slist);
To copy to clipboard, switch view to plain text mode
Bookmarks