QProgressDialog 借鉴及界面优化

QProgressDialog

//.h文件中定义
#include <QProgressDialog>
QProgressDialog *process;


//.cpp中按键按下时槽函数实现如下:
void MainWindow::on_pushButton_3_clicked()
{

    process = new QProgressDialog(this);
    process->setLabelText("test....");
    process->setRange(0,1000);
    process->setCancelButtonText(tr("取消"));
    process->setModal(true);
    process->setStyleSheet("QProgressBar{border:1px solid #FFFFFF;"
                           "height:30;"
                           "background:red;"
                           "text-align:center;"
                           "color:rgb(255,255,0);"
                           "border-radius:10px;}"
                           "QProgressBar::chunk{"
                           "border-radius:3px;"    // 斑马线圆角
                           "border:0.5px "
                           "solid green;" // 黑边,默认无边
                           "background-color:blue;}");

// 取消按键的关联,connect(process,SIGNAL(canceled()),this,SLOT(processcanceled()));

    for(int i=0;i<=1000;i++)
    {
        qDebug()<<"setvalue i = "<<i;
        for(int j=0;j<20000;j++);
        process->setValue(i);
        if(process->wasCanceled())//检测是否取消
        {
            delete process;
            break;

        }

    }
 }

QProgressDialog 借鉴及界面优化_第1张图片

你可能感兴趣的:(QT控件)