当前位置: 首页 > news >正文

建设对公银行网站打不开赣州网站网站建设

建设对公银行网站打不开,赣州网站网站建设,茂名免费网站建设,WordPress自然志主题笔者为这个问题思索了不少时间#xff0c;这个问题就是c qt里创建了一个QStandardItemModel设置了表格的表头#xff0c;往表格填充数据时#xff0c;数据的复选框左对齐#xff0c;想要设置复选框居中对齐#xff0c;不知道如何处理#xff0c;这里给出代码与运行效果这个问题就是c qt里创建了一个QStandardItemModel设置了表格的表头往表格填充数据时数据的复选框左对齐想要设置复选框居中对齐不知道如何处理这里给出代码与运行效果未来出现同样的问题时可以拿来参考 文章目录 问题来源问题解决方案主要效果 问题来源 c qt里想要设置QTableView复选框居中对齐不知道如何处理。 问题解决方案 给出自己的亲测有效的方法并附上代码效果。使用委托 函数定义 #include QStyledItemDelegate #include QPainterclass CenteredCheckBoxDelegate : public QStyledItemDelegate {Q_OBJECT public:using QStyledItemDelegate::QStyledItemDelegate;bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem option, const QModelIndex index);void paint(QPainter* painter, const QStyleOptionViewItem option, const QModelIndex index) const override; }; 函数实现 void CenteredCheckBoxDelegate::paint(QPainter* painter, const QStyleOptionViewItem option, const QModelIndex index) const {QStyleOptionButton checkBoxOption;checkBoxOption.state | QStyle::State_Enabled;if (index.model()-data(index, Qt::CheckStateRole).toBool()) {checkBoxOption.state | QStyle::State_On;}else {checkBoxOption.state | QStyle::State_Off;}bool isSelected option.state QStyle::State_Selected;bool hasFocus option.state QStyle::State_HasFocus;if (isSelected || hasFocus) {painter-fillRect(option.rect, QColor(240, 240, 240)); // 选中或有焦点时的颜色}else {QColor backgroundColor;if (index.row() % 2 0) {backgroundColor QColor(255, 255, 255); // 偶数行}else {backgroundColor QColor(244, 246, 248); // 奇数行}painter-fillRect(option.rect, backgroundColor); // 未选中或没有焦点时的颜色}QRect checkBoxRect QApplication::style()-subElementRect(QStyle::SE_CheckBoxIndicator, checkBoxOption, option.widget);checkBoxRect.moveCenter(option.rect.center()); painter-save();painter-translate(checkBoxRect.center());QApplication::style()-drawControl(QStyle::CE_CheckBox, checkBoxOption, painter, option.widget);painter-restore(); } bool CenteredCheckBoxDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem option, const QModelIndex index) {if (event-type() QEvent::MouseButtonRelease) {QMouseEvent *mouseEvent static_castQMouseEvent*(event);if (option.rect.contains(mouseEvent-pos())) {// 检查该项是否可选可选性数据需要在模型的某个地方被设置bool isCheckable model-data(index, Qt::UserRole).toBool(); // 假设你在Qt::UserRole存储了可选性if (isCheckable) {// 改变选中状态bool checked model-data(index, Qt::CheckStateRole).toBool();model-setData(index, !checked, Qt::CheckStateRole);return true;}}}return QStyledItemDelegate::editorEvent(event, model, option, index); // 对于其他事件保持默认处理 } 代码含义讲解这段代码主要讲解了复选框居中对齐以及复选框如果选中会变颜色的操作 主要效果
http://www.pierceye.com/news/871512/

相关文章:

  • 旅游地网站制作有没有做网站的高手
  • 有什么网站可以做一起作业什么网站可以兼职做效果图
  • 工程中标查询网站长沙网站制作作
  • 免费网站下载直播软件企业品牌网站建设类型
  • 建立网站并以此为基础从事经营活动的企业称为什么免费销售网站模板
  • 成都市建设质监站网站微信企业网站html5模板
  • 福建工程建设管理中心网站仙桃做企业网站的
  • 孝感做网站的公司建网站是永久的吗
  • 厦门手机建站php网站开发推荐书籍
  • 属于c2c网站的有哪几个方庄网站制作
  • 建设局网站模板iis 网站没有上传权限
  • 建设网站龙华怎么用自己的电脑搭建网站
  • 分析网站的网站福建交科建设有限公司官方网站
  • 深圳南园网站建设网站域名怎么设置方法
  • 网站的内链是什么意思网页布局有哪几种方法
  • 网站优化公司上海山东电力建设河北分公司网站
  • 甘肃省住房和城乡建设部网站首页专门网页制作工具有
  • 网站用vps做dns做网站的叫什么职位
  • 网站开发业务流程图网站商城与网站区别吗
  • 用新浪微博做网站百度找不到 网站
  • 哪个网站做照片书最好seo投放是什么意思
  • 书店网站开发目的和意义深圳网建公司
  • 餐饮网站方案wordpress 微论坛主题
  • 上海建筑网站设计多用户商城数据库设计
  • 网站做301将重定向到新域名深圳seo优化外包公司
  • 做视频导航网站有哪些天津西青区离哪个火车站近
  • 福州网站建设技术支持公司培训课程有哪些
  • 保定网站制作域名注册商查询
  • 医院网站建设公司价格低天津建设工程信息网 塘沽一中
  • 建设机械网站案例建国外网站需要多少钱