• 7546阅读
  • 1回复

【提问】layout 例子的问题 [复制链接]

上一主题 下一主题
离线zksunk
 

只看楼主 倒序阅读 楼主  发表于: 2006-01-19
例子中用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??
离线XChinux

只看该作者 1楼 发表于: 2006-01-19
你的指针ed的作用域就在for循环块中,一出来这个指针就没了。
这是C/C++的东西,看一下变量作用域方面的知识。
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
快速回复
限100 字节
 
上一个 下一个