Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/139.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何编辑QCombobox的当前文本?_C++_Qt - Fatal编程技术网

C++ 如何编辑QCombobox的当前文本?

C++ 如何编辑QCombobox的当前文本?,c++,qt,C++,Qt,我想编辑QComboBox的当前文本 QString nome = ui->taxas_existentes->currentText(); 我有这个,但是如果最初的文本是“Test”,我改为“Test1”,变量“nome”将有“Test”作为值,而不是“Test1” 编辑: 我有这个,然后我点击编辑图标 我将名称“Teste”更改为“Teste1”,然后单击绿色图标 然后,单击绿色图标后,我得到以下代码: QString nome = ui->taxas_existen

我想编辑QComboBox的当前文本

QString nome = ui->taxas_existentes->currentText();
我有这个,但是如果最初的文本是“Test”,我改为“Test1”,变量“nome”将有“Test”作为值,而不是“Test1”

编辑:

我有这个,然后我点击编辑图标

我将名称“Teste”更改为“Teste1”,然后单击绿色图标

然后,单击绿色图标后,我得到以下代码:

QString nome = ui->taxas_existentes->currentText();
变量nome的值为“Teste”,而不是“Teste1”

编辑2:

        void WidgetDefinicoes::on_editar_taxa_clicked()
    {
        GereTaxa gereTaxas = GereTaxa();
        if(ui->taxas_existentes->isEditable()) {
            ui->taxas_existentes->setEditable(false);

            QString nome = ui->taxas_existentes->currentText();

            if(!nome.isEmpty()){

                    GereTaxa gereTaxa = GereTaxa();
                    int idTaxa = gereTaxas.obtemId(taxas.at(0)->getNome());
                    if(nome == taxas.at(0)->getNome()) {
                        Taxa * taxa = new Taxa(idTaxa, taxaInt, nome);
                        qDebug() << taxa->getTaxa();
                        qDebug() << taxa->getNome();

                        if(gereTaxa.editTaxa(* taxa) == 1) {
                           QMessageBox::information(this,tr("SalesQ"),tr("A taxa foi alterada com sucesso!"));
                        } else {
                           QMessageBox::warning(this,tr("SalesQ"),tr("Ocorreu um erro a alterar a taxa!"));
                        }
                   }
          }
}
void WidgetDefinicoes::on_editar_taxa_clicked()
{
GereTaxa gereTaxas=GereTaxa();
如果(ui->taxas\u existentes->isEditable()){
ui->taxas\u existentes->setEditable(false);
QString nome=ui->taxas_existentes->currentText();
如果(!nome.isEmpty()){
GereTaxa GereTaxa=GereTaxa();
intidtaxa=gereTaxas.obtemId(taxas.at(0)->getNome());
如果(nome==taxas.at(0)->getNome()){
分类群*分类群=新分类群(分类群、分类群、命名);
qDebug()getTaxa();
qDebug()getNome();
如果(gereTaxa.EDITAXA(*taxa)==1){
QMessageBox::信息(this,tr(“SalesQ”)、tr(“一个成功的分类群”);
}否则{
警告(this,tr(“SalesQ”)、tr(“Ocorreu um erro a alterar a taxa!”);
}
}
}
}
找到了错误

ui->taxas_existentes->setEditable(false);
一定是

QString nome = ui->taxas_existentes->currentText();
而不是在发现错误之前

ui->taxas_existentes->setEditable(false);
一定是

QString nome = ui->taxas_existentes->currentText();

而不是在之前,你能提供一个关于你的问题的最小、完整和可复制的例子吗?因为在更改
QComboBox
后获取当前项目的文本效果很好。完成了…我在editImages上放了更多的图像现在不见了…请。你能提供一个关于你的问题的最小、完整和可复制的例子吗因为更改后获取
QComboBox
当前项的文本效果很好。完成…我在编辑中添加了更多图像图像现在不可见…请。