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.
我正在用qt制作一个计算器。我有一个纯文本编辑框。当我在其中输入数字时,我希望它从右侧打印(就像任何其他计算器一样)。
另外,我想禁用除数字以外的任何内容的输入。(qt中的小新)
您只需要使用setAlignment(Qt::AlignRight)您的 QLineEdit 和
setAlignment(Qt::AlignRight)
QLineEdit::setValidator(), 例如:
QLineEdit::setValidator()
myLineEdit->setValidator( new QIntValidator(0, 100, this) );
也看看这个:Set QLineEdit to accept only numbers