Qt:自定义 LineEditDelegate 的绘制功能
Qt: Paint function of custom LineEditDelegate
我已经实现了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
类吗?如果有人做过,你能分享你的代码吗?
试试这个答案。
它使用带有QStyle::PE_PanelLineEdit
元素的QStyle::drawPrimitive
。
相关文章:
- 在执行其他功能的同时播放动画(LED矩阵和Arduino/ESP8266)
- 多态性和功能结合
- 带内存和隔离功能的SQLite
- 在CMakeLists.txt的安装功能中使用.cmake文件有什么用
- 类模板的成员功能的定义在单独的TU中完全专业化
- 有没有一种方法可以创建一个带有哈希表的数据库,该哈希表具有恒定时间查找功能
- 如何在C++中获得"静态纯虚拟"功能?
- QuadTree只在窗口的右上角绘制
- 绘制旋转的三角形
- 两个文件使用彼此的功能-如何解决
- 我应该实现右值推送功能吗?我应该使用std::move吗
- QML按钮点击功能执行顺序
- flutter:即使shouldRepaint()返回true,自定义画家也不会重新绘制
- 无法理解此 return 语句的功能,没有它就会发生运行时错误
- 有没有可能有一个只有ADL才能找到的非好友功能
- 如何使用两个功能在C++中绘制空心钻石
- 在网格中绘制具有捕捉功能的线条
- Qt:自定义 LineEditDelegate 的绘制功能
- 绘制图像的功能
- 在"margin"中绘制为 IDE/编辑器功能