How to make item view render rich (html) text in Qt
来源:互联网 发布:s3c2410数据手册 编辑:程序博客网 时间:2024/05/17 04:25
class HtmlDelegate : public QStyledItemDelegate{protected: void paint ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const; QSize sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const;};void HtmlDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const{ QStyleOptionViewItemV4 optionV4 = option; initStyleOption(&optionV4, index); QStyle *style = optionV4.widget? optionV4.widget->style() : QApplication::style(); QTextDocument doc; doc.setHtml(optionV4.text); /// Painting item without text optionV4.text = QString(); style->drawControl(QStyle::CE_ItemViewItem, &optionV4, painter); QAbstractTextDocumentLayout::PaintContext ctx; // Highlighting text if item is selected if (optionV4.state & QStyle::State_Selected) ctx.palette.setColor(QPalette::Text, optionV4.palette.color(QPalette::Active, QPalette::HighlightedText)); QRect textRect = style->subElementRect(QStyle::SE_ItemViewItemText, &optionV4); painter->save(); painter->translate(textRect.topLeft()); painter->setClipRect(textRect.translated(-textRect.topLeft())); doc.documentLayout()->draw(painter, ctx); painter->restore();}
- How to make item view render rich (html) text in Qt
- How to render "asp:Label" as "label" in HTML markup.
- How to display fields in the frontend item view
- jade engine,how to render static html?
- How to make text of an html checkbox clickable (like ASP.NET control)
- How to change the Text color of Menu item in Android?
- How to Use OLE in Rich Edit Controls
- How to Render Image Buffer in Android NDK Native Code
- How to Render Image Buffer in Android NDK Native Code
- How to enter text into a textfield in a web view using UIAutomation
- How to put a space character before option text in a HTML select element?
- JS. How to replace html element with another element/text, represented in string?
- How to fit text in rectangle-MSDN
- How to be the rich?
- UIView Tutorial for iOS: How To Make a Custom UIView in iOS 5: A 5 Star Rating View
- How to invoke the method of managed bean and render view in JSF when we are outside the lifecycle of JSF
- How to Rename a View in ClearCase
- How to Rename a View in ClearCase
- TS流播放器 开源免费播放器VLC Media Player
- 关于varying的理解
- VC多线程编程之线程创建与示例
- iOS 7 SDK: 如何使用后台获取(Background Fetch)
- Android 设置无标题栏(全屏)的两种方式
- How to make item view render rich (html) text in Qt
- Gearman分布式任务处理系统(六)跨多种环境部署
- JQuery validate ajax 表单验证方法。
- [Android实例] android实现顶级圆角弹窗(个人)
- 第十五章——抽象类,切片,多继承
- C++中float和double
- [LeetCode] Partition List
- Android平台Bitmap缓存为文件
- Reporting Service2008 匿名访问报表服务器2008配置