21,489
社区成员
发帖
与我相关
我的任务
分享form1::form1( QWidget* parnet = 0, const char* name = 0, WFlags f = 0 )
: QWidget( parent, name, f )
{
QComboBox* box = new QComboBox( this, "box" );
/* 第一种写法,编译无错,在终端中运行,提示“QComboBox(box)-index 1 out of range”*/
init();
langChange();
/* 第二种写法,编译无错,在终端中运行时,也无任何提示 */
langChange();
init();
}
langChange()
{
box->clear();
box->insertItem( "item0", 0 );
box->insertItem( "item1", 1 );
}
void form1::init()
{
box->setCurrentItem( 1 );
}QComboBox* box = new QComboBox( this, "box" );
langChange();
init();