【问题标题】:Qt: Paint function of custom LineEditDelegateQt:自定义LineEditDelegate的画图功能
【发布时间】:2013-09-17 06:28:47
【问题描述】:

我已经实现了 ComboBoxDelegate。它源自QStyledItemDelegate。绘制功能用于在未编辑节点时显示单元格的内容。

void ComboBoxDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {
    QStyleOptionComboBox comboBoxOption;
    comboBoxOption.rect = option.rect;
    comboBoxOption.state = QStyle::State_Active | QStyle::State_Enabled;
    comboBoxOption.frame = true;
    comboBoxOption.currentText = index.model()->data(index).toString();
    QApplication::style()->drawComplexControl(QStyle::CC_ComboBox, &comboBoxOption, painter);
    QApplication::style()->drawControl(QStyle::CE_ComboBoxLabel, &comboBoxOption, painter);
}

现在我正在尝试实现 LineEditDelegate。我不知道如何编写它的绘画功能。 QLineEdit 是否有 QStyleOptionComboBox 之类的课程?如果有人做过,请分享您的代码吗?

【问题讨论】:

    标签: c++ qt delegates paint qlineedit


    【解决方案1】:

    试试this answer

    它使用QStyle::drawPrimitiveQStyle::PE_PanelLineEdit 元素。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-01-09
      • 2013-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多