QLabel setText不起作用

时间:2016-01-26 07:39:10

标签: c++ qt

我有这样的功能

void CTabPage2::PresentData()
{
    CFuncLog log("CTabPage2::PresentData");

    QList<QLabel*> labintr;
    QList<QLabel*> labpic;
    labintr<<m_ui->labintr_1<<m_ui->labintr_2<<m_ui->labintr_3<<m_ui->labintr_4<<m_ui->labintr_5<<m_ui->labintr_6;
    labpic<<m_ui->labpic_1<<m_ui->labpic_2<<m_ui->labpic_3<<m_ui->labpic_4<<m_ui->labpic_5<<m_ui->labpic_6;

    for(int i=0;i<6;++i)
    {
        QString index=QString::number(i);
        QJsonObject person;
        person=p_info[p_map[index].toString()].toObject();
        QString qsPersonInfo=QString("工号:%1\n姓名:%2\n在岗职位:%3\n在岗级别:%4\n"
                                             "文化程度:%5\n出生年月:%6\n入职时间:%7\n备注信息:%8\n")
                         .arg(person["id"].toString())
                        .arg(person["name"].toString())
                        .arg(person["position"].toString())
                        .arg(person["level"].toString())
                        .arg(person["degree"].toString())
                        .arg(person["birth"].toString())
                        .arg(person["joindate"].toString())
                        .arg(person["comments"].toString());


        labintr.at(i)->setText(qsPersonInfo);      ***//this do not work,nothing show in the label;***
        qDebug()<<labintr.at(i)->text();    //this work well
        labintr.at(i)->setStyleSheet("color:red");    //this work well
        //m_ui->labintr_1->setText(qsPersonInfo);  //this work well
        //m_ui->lab_info1->setText(qsPersonInfo);  //this work well
        QString filename=QDir::currentPath()+"/person/"+person["image"].toString();
        QImage img(filename);
        labintr.at(i)->setPixmap(QPixmap::fromImage(img));
    }
}
  

我的ui文件示例中有一些QLabel示例labintr_ * labpic _ *,我把   他们在QList中的指针,一切正常,但是   anotation part,标签上没有显示,谁能告诉我为什么?   the run page like this

0 个答案:

没有答案