本文整理汇总了C++中CComboBox::addItem方法的典型用法代码示例。如果您正苦于以下问题:C++ CComboBox::addItem方法的具体用法?C++ CComboBox::addItem怎么用?C++ CComboBox::addItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComboBox
的用法示例。
在下文中一共展示了CComboBox::addItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addWidget
void JabberSearch::addWidget(JabberAgentInfo *data)
{
QWidget *widget = NULL;
bool bJoin = false;
if (data->Type){
if (!strcmp(data->Type, "x")){
m_bXData = true;
}else if (!strcmp(data->Type, "text-single")){
widget = new QLineEdit(this, data->Field);
connect(widget, SIGNAL(returnPressed()), m_receiver, SLOT(search()));
connect(widget, SIGNAL(textChanged(const QString&)), m_receiver, SLOT(textChanged(const QString&)));
}else if (!strcmp(data->Type, "fixed") || !strcmp(data->Type, "instructions")){
if (data->Value){
QString text = i18(data->Value);
text = text.replace(QRegExp(" +"), "\n");
QLabel *label = new QLabel(text, this);
label->setAlignment(WordBreak);
widget = label;
bJoin = true;
}
}else if (!strcmp(data->Type, "list-single")){
CComboBox *box = new CComboBox(this, data->Field);
for (unsigned i = 0; i < data->nOptions; i++){
const char *label = get_str(data->OptionLabels, i);
const char *val = get_str(data->Options, i);
if (label && val)
box->addItem(i18(label), val);
}
widget = box;
}else if (!strcmp(data->Type, "key")){
if (data->Value)
m_key = data->Value;
}else if (!strcmp(data->Type, "password")){
widget = new QLineEdit(this, "password");
static_cast<QLineEdit*>(widget)->setEchoMode(QLineEdit::Password);
connect(widget, SIGNAL(returnPressed()), m_receiver, SLOT(search()));
connect(widget, SIGNAL(textChanged(const QString&)), m_receiver, SLOT(textChanged(const QString&)));
set_str(&data->Label, "Password");
}else if (!strcmp(data->Type, "online")){
widget = new QCheckBox(this, "online");
static_cast<QCheckBox*>(widget)->setText(i18n("Online only"));
bJoin = true;
}else if (!strcmp(data->Type, "sex")){
CComboBox *box = new CComboBox(this, data->Field);
box->addItem("", "0");
box->addItem(i18n("Male"), "1");
box->addItem(i18n("Female"), "2");
set_str(&data->Label, I18N_NOOP("Gender"));
widget = box;
}else{
defFlds *f;
for (f = fields; f->tag; f++)
if (!strcmp(data->Type, f->tag))
break;
if (f->tag){
widget = new QLineEdit(this, f->tag);
connect(widget, SIGNAL(returnPressed()), m_receiver, SLOT(search()));
connect(widget, SIGNAL(textChanged(const QString&)), m_receiver, SLOT(textChanged(const QString&)));
set_str(&data->Label, f->name);
}else if (data->Label){
widget = new QLineEdit(this, f->tag);
connect(widget, SIGNAL(returnPressed()), m_receiver, SLOT(search()));
connect(widget, SIGNAL(textChanged(const QString&)), m_receiver, SLOT(textChanged(const QString&)));
}
}
}
if (widget){
if (data->bRequired)
m_required.push_back(widget);
if (bJoin){
lay->addMultiCellWidget(widget, m_nPos, m_nPos, 0, 1);
}else{
lay->addWidget(widget, m_nPos, 1);
if (data->Label){
QLabel *label = new QLabel(i18(data->Label), this);
label->setAlignment(AlignRight);
lay->addWidget(label, m_nPos, 0);
label->show();
}
}
widget->show();
m_nPos++;
m_bDirty = true;
QTimer::singleShot(0, this, SLOT(setSize()));
}
}
示例2: addWidget
void JabberSearch::addWidget(JabberAgentInfo *data)
{
QWidget *widget = NULL;
bool bJoin = false;
if (!data->Type.str().isEmpty()){
if (data->Type.str() == "x"){
m_bXData = true;
vector<QWidget*>::iterator it;
for (it = m_widgets.begin(); it != m_widgets.end(); ++it)
if (*it)
delete (*it);
m_widgets.clear();
for (it = m_labels.begin(); it != m_labels.end(); ++it)
if (*it)
delete (*it);
m_labels.clear();
for (it = m_descs.begin(); it != m_descs.end(); ++it)
if (*it)
delete (*it);
m_descs.clear();
m_instruction = QString::null;
}else if (data->Type.str() == "title"){
if (!data->Value.str().isEmpty())
m_title = data->Value.str();
}else if (data->Type.str() == "text-single"){
widget = new QLineEdit(this, data->Field.str());
connect(widget, SIGNAL(returnPressed()), m_receiver, SLOT(search()));
connect(widget, SIGNAL(textChanged(const QString&)), m_receiver, SLOT(textChanged(const QString&)));
if (!data->Value.str().isEmpty())
static_cast<QLineEdit*>(widget)->setText(data->Value.str());
}else if (data->Type.str() == "text-private"){
widget = new QLineEdit(this, data->Field.str());
static_cast<QLineEdit*>(widget)->setEchoMode(QLineEdit::Password);
connect(widget, SIGNAL(returnPressed()), m_receiver, SLOT(search()));
connect(widget, SIGNAL(textChanged(const QString&)), m_receiver, SLOT(textChanged(const QString&)));
if (!data->Value.str().isEmpty())
static_cast<QLineEdit*>(widget)->setText(data->Value.str());
}else if (data->Type.str() == "text-multi"){
widget = new QMultiLineEdit(this, data->Field.str());
connect(widget, SIGNAL(returnPressed()), m_receiver, SLOT(search()));
if (!data->Value.str().isEmpty())
static_cast<QMultiLineEdit*>(widget)->setText(data->Value.str());
}else if (data->Type.str() == "boolean" && !data->Label.str().isEmpty()){
widget = new QCheckBox(data->Label.str(), this, data->Field.str());
if (!data->Value.str().isEmpty() && !data->Value.str().startsWith("0"))
static_cast<QCheckBox*>(widget)->setChecked(true);
data->Label.clear();
bJoin = true;
}else if (data->Type.str() == "fixed"){
if (!data->Value.str().isEmpty()){
QString text = i18(data->Value.str());
text = text.replace(QRegExp(" +"), "\n");
if (m_bFirst){
if (!m_label.isEmpty())
m_label += '\n';
m_label += text;
}else{
QLabel *label = new QLabel(text, this);
label->setAlignment(WordBreak);
widget = label;
bJoin = true;
}
}
}else if (data->Type.str() == "instructions"){
if (!data->Value.str().isEmpty()){
QString text = i18(data->Value.str());
text = text.replace(QRegExp(" +"), "\n");
if (!m_instruction.isEmpty())
m_instruction += '\n';
m_instruction += text;
}
}else if (data->Type.str() == "list-single"){
CComboBox *box = new CComboBox(this, data->Field.str());
int cur = 0;
int n = 0;
for (unsigned i = 0; i < data->nOptions.toULong(); i++){
QString label = get_str(data->OptionLabels, i);
QString val = get_str(data->Options, i);
if (label && val){
box->addItem(i18(label), val);
if (data->Value.str() == val)
cur = n;
n++;
}
}
box->setCurrentItem(cur);
widget = box;
}else if (data->Type.str() == "key"){
if (!data->Value.str().isEmpty())
m_key = data->Value.str();
}else if (data->Type.str() == "password"){
widget = new QLineEdit(this, "password");
static_cast<QLineEdit*>(widget)->setEchoMode(QLineEdit::Password);
connect(widget, SIGNAL(returnPressed()), m_receiver, SLOT(search()));
connect(widget, SIGNAL(textChanged(const QString&)), m_receiver, SLOT(textChanged(const QString&)));
data->Label.str() = "Password";
}else if (data->Type.str() == "online"){
widget = new QCheckBox(this, "online");
static_cast<QCheckBox*>(widget)->setText(i18n("Online only"));
bJoin = true;
//.........这里部分代码省略.........