QT中ComboBox如何获取选中的文本内容??下面程序出错了,如何改正?
改为下面这个还是不行,哪位给指点一下啊??ComboBox=newQComboBox(groupBox);ComboBox->addItem(QObject::tr("/...
改为下面这个还是不行,哪位给指点一下啊??
ComboBox = new QComboBox(groupBox);
ComboBox->addItem(QObject::tr("/home/apuser/qt6"));
ComboBox->addItem(QObject::tr("/home/apuser/qt1"));、
connect(ComboBox,SIGNAL(activated(int)),this,SLOT(doSelectFont(int))); QString QComboBox::currentText (); 展开
ComboBox = new QComboBox(groupBox);
ComboBox->addItem(QObject::tr("/home/apuser/qt6"));
ComboBox->addItem(QObject::tr("/home/apuser/qt1"));、
connect(ComboBox,SIGNAL(activated(int)),this,SLOT(doSelectFont(int))); QString QComboBox::currentText (); 展开
展开全部
错误代码都没有呢?估计是你定义的SLOT有问题。
你看看我写的这段代码吧,是选取QComboBox控件中的文本内容的。
intmain(intargc,char**argv)
{
QApplicationapp(argc,argv);
QComboBox*comboBox=newQComboBox;
QTextEdit*textEdit=new QTextEdit;
QVBoxLayout*layout=new QVBoxLayout;
layout->addWidget(textEdit);
layout->addWidget(comboBox);
comboBox->addItem(QObject::tr("ComboBoxItem01"));
comboBox->addItem(QObject::tr("ComboBoxItem02"));
comboBox-addItem(QObject::tr("ComboBoxItem03"));
QObject::connect(comboBox,SIGNAL(activated(QString)),textEdit,SLOT(insertPlainText(QString)));
QWidget mainWin;
mainWin.setLayout(layout);
mainWin.resize(770,550);
mainWin.show();
returnapp.exec();
}
你看看我写的这段代码吧,是选取QComboBox控件中的文本内容的。
intmain(intargc,char**argv)
{
QApplicationapp(argc,argv);
QComboBox*comboBox=newQComboBox;
QTextEdit*textEdit=new QTextEdit;
QVBoxLayout*layout=new QVBoxLayout;
layout->addWidget(textEdit);
layout->addWidget(comboBox);
comboBox->addItem(QObject::tr("ComboBoxItem01"));
comboBox->addItem(QObject::tr("ComboBoxItem02"));
comboBox-addItem(QObject::tr("ComboBoxItem03"));
QObject::connect(comboBox,SIGNAL(activated(QString)),textEdit,SLOT(insertPlainText(QString)));
QWidget mainWin;
mainWin.setLayout(layout);
mainWin.resize(770,550);
mainWin.show();
returnapp.exec();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询