⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 penstyledelegate.cpp

📁 本文件是<精通QT4编程>的配套源代码
💻 CPP
字号:
//// C++ Implementation: penstyledelegate//// Description: ////// Author: zeki <czm@zeki>, (C) 2007//// Copyright: See COPYING file that comes with this distribution////#include "penstyledelegate.h"QPenStyleDelegate::QPenStyleDelegate(QObject *parent)    : QAbstractItemDelegate(parent){}void QPenStyleDelegate::paint(QPainter *painter,                                const QStyleOptionViewItem &option,                                const QModelIndex &index) const{    QString text = index.data(Qt::DisplayRole).toString();    Qt::PenStyle penStyle = (Qt::PenStyle)index.data(Qt::UserRole).toInt();    QRect r = option.rect;    if (option.state & QStyle::State_Selected) {        painter->save();        painter->setBrush(option.palette.highlight());        painter->setPen(Qt::NoPen);        painter->drawRect(option.rect);        painter->setPen(QPen(option.palette.highlightedText(),2, penStyle));    }    else    	painter->setPen(penStyle);    painter->drawLine(0, r.y() + r.height()/2, r.right(), r.y() + r.height()/2);    if (option.state & QStyle::State_Selected)        painter->restore();}QSize QPenStyleDelegate::sizeHint(const QStyleOptionViewItem &option,                                    const QModelIndex &index) const{    return QSize(100,30);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -