문제

The statement is:

int nmbr;
QString strngs;

for( nmbr = 62; nmbr <65; nmbr++)
{
   strngs=(QString)"qDebug()<<(QString)ui->label_"+QString::number(nmbr)+"->text();";
}

Actually I want to access QLabels, a lot of them and extract their text for using at some other place.

Thanks!

도움이 되었습니까?

해결책

Are you trying to get the text from a lot of QLabels of a current widget?

Then you'd better do something like that:

for( int nmbr = 62; nmbr <65; nmbr++)
{
    QString labelname = QString("label_%1") .arg( nmbr );
    QLabel * label = findChild<QLabel*>( labelname );

    if ( label )
        qDebug() << label->text();
}

Is this what you're looking for?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top