Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
为什么当位数小于 QLCDNumber 参数中允许的位数时 QLCDNumber 数字不能居中?我可以绕过这个吗?
作为一种解决方法,您可以在每次设置新值时设置位数:
ui->lcdNumber->display(value); ui->lcdNumber->setDigitCount(QString("%1").arg(value).length());
这里QString("%1").arg(value).length()返回 中的位数value。当您正确设置它时,它将正确对齐。
QString("%1").arg(value).length()
value