How can I add item in the QCombobox?
Solved
General and Desktop
-
Hi All,
I'm using qt5.5 and Linux+QT for my OS system.
This is how I designed.void MainWindow::openscanwindow() { int i = 0; bool empty = false; QString scan_info; QString info; stackedWidgetTestbtselect=ui->stackedWidgetPagePanel; ui->stackedWidget->setCurrentWidget(stackedWidgetTestbtselect); btselect = new QComboBox(this); btselect->setEditable(true); Process::executeProcessSync(QString("sh"),QStringList()<<"-c"<<"/bin/touch /home/bt.txt",&info); qDebug()<<"touch: "+info; Process::executeProcessSync(QString("sh"),QStringList()<<"-c"<<"/usr/bin/hciconfig hci0 piscan",&info); qDebug()<<"piscan: "+info; Process::executeProcessSync(QString("sh"),QStringList()<<"-c"<<"/usr/bin/hcitool scan > /home/bt.txt",&info); qDebug()<<"scan: "+info; QString jump; QFile scan("/home/bt.txt"); if(!scan.open(QIODevice::ReadOnly|QIODevice::Text)) { qDebug("cannot open bt.txt"); } else { jump = scan.readLine(); while(!empty) { scan_info=scan.readLine(); qDebug()<<scan_info; if(scan_info.isEmpty()) { empty = true; } else { scan_info = scan_info.mid(19).trimmed(); qDebug()<<scan_info; btselect->addItem(scan_info); } } } }
I can't show anything out in my Combobox.
How can I solve this problem?
Thanks in Advanced!
-
@victor-wang said in How can I add item in the QCombobox?:
else { scan_info = scan_info.mid(19).trimmed(); qDebug()<<scan_info; btselect->addItem(scan_info); }
Does it print anything?
-
void MainWindow::openscanwindow() { bselect = new QComboBox(this); bselect->addItem("New Item"); }
Could it be just a test to work in this case?
-
@victor-wang
Yes.
The more detailed problem was the followingbtselect = new QComboBox(this);
You may have been using it for some time but btselect = new QComboBox (this); He spoiled everything.
Combobox cleaned. He's the other and no longer watches the previous address.
If you use it only in the constructor then everything would be fine :)) -
@victor-wang
sorry for english.
Hopefully there will be someone who is godly and you will explain in detail.