首页| 论坛| 消息

标题:【提问】layout 例子的问题
作者:zksunk
日期:2006-01-19 16:16
内容:

例子中用for循环创建了三个lineedit,怎么访问啊
for ( row = 0; row < numRows; row++ ) {
QLineEdit *ed = new QLineEdit( this );
// The line edit goes in the second column
grid->addWidget( ed, row, linedCol );
// Make a label that is a buddy of the line edit
QString s;
s.sprintf( "Line &%d", row+1 );
QLabel *label = new QLabel( ed, s, this );
// The label goes in the first column.
grid->addWidget( label, row, labelCol );
}
ed->setText(), ed1->setText();都不行,我应该怎么分别访问那lineedit??


#1 [XChinux 01-19 16:31]
你的指针ed的作用域就在for循环块中,一出来这个指针就没了。
这是C/C++的东西,看一下变量作用域方面的知识。

回复 发表
主题 版块