码迷,mamicode.com
首页 > 其他好文 > 详细

Qt532.QString_填充字符

时间:2017-12-22 12:24:51      阅读:95      评论:0      收藏:0      [点我收藏+]

标签:ring   button   click   字符   push   qstring   body   post   deb   

1、代码:

void MainWindow::on_pushButton_clicked()
{
    QString str = "5";
    QString str01 = str.leftJustified(3, 0);
    qDebug() << str01;
    str01 = str.rightJustified(5, 0);
    qDebug() << str01;
    str01 = str.rightJustified(2, 0);
    qDebug() << str01;
}

 

2、控制台输出:

"500"
"00005"
"05"

 

3、

4、

5、

 

Qt532.QString_填充字符

标签:ring   button   click   字符   push   qstring   body   post   deb   

原文地址:http://www.cnblogs.com/cppskill/p/8085270.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!