代码之家  ›  专栏  ›  技术社区  ›  Narek

字体大小QComboBox项目?

  •  3
  • Narek  · 技术社区  · 14 年前

    1 回复  |  直到 14 年前
        1
  •  6
  •   user362638 user362638    14 年前

    class RowHeightDelegate : public QItemDelegate
    {
        Q_OBJECT
    public:
        QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const
        {
            return QSize(1, 40); // the row height is now 40
        }
    };
    

    并将其设置为您的组合框:

    ui->comboBox->setItemDelegate(new RowHeightDelegate());
    

    编辑:

    上面的示例显示了如何更改下拉列表的行高。字体大小不变。如果要更改整个组合框(包括下拉列表)的字体大小,请创建具有所需大小的新字体并将其设置为组合框:

    QFont font;
    font.setPointSize(font.pointSize() + 10);
    ui->comboBox->setFont(font);