Question

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!

Was it helpful?

Solution

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?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top