QMessageBox 显示文字对齐的实现

来源:互联网 发布:python爬虫赚钱收入 编辑:程序博客网 时间:2024/04/30 23:21

 

 

class MessageBox : public QMessageBox
{
protected:
    void showEvent(QShowEvent* event){
        QMessageBox::showEvent(event);
        QWidget *textField = findChild<QWidget*>("qt_msgbox_label");
        if(textField != NULL)
        {

            设置QMessageBox的最小大小
            textField->setMinimumSize(WMH_CURRENT_W(432), WMH_CURRENT_W(40));;     

        }
        QList<QLabel *> textFieldLabels = findChildren<QLabel*>();
        for(int i=0; i < textFieldLabels.size(); i++)
        {
            textFieldLabels.at(i)->setAlignment(Qt::AlignCenter);

            //设置文字显示的对齐方式
        }
    }
};
 

原创粉丝点击