QComboBox设置文字居中

  1. 1 设置显示文字居中
  2. 2 设置弹出文本居中

1 设置显示文字居中

可以重新设置LineEdit控件

    QLineEdit *lineEdit = new QLineEdit(this);
    lineEdit->setReadOnly(true);
    lineEdit->setAlignment(Qt::AlignCenter);

2 设置弹出文本居中

qobject_cast<QStandardItemModel*>(m_comboBox->view()->model())->item(m_comboBox->count()-1)->setTextAlignment(Qt::AlignCenter);

转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 add358@163.com

文章标题:QComboBox设置文字居中

文章字数:60

本文作者:Jake Yang

发布时间:2018-10-25, 00:00:00

最后更新:2019-12-16, 16:14:19

原始链接:https://add358.github.io/2018/10/25/Libs-Qt-2018-10-25-QComboBox设置文字居中/

版权声明: "署名-非商用-相同方式共享 4.0" 转载请保留原文链接及作者。

目录
×

喜欢就点赞,疼爱就打赏