Anti-Aliasing doesn't work with QWebFrame.render()
-
I use QWebPage (without QWebView) as a delegate for QListView. Here is the simple code. It is works, but it doesn't support Anti-Aliasing, the fonts look ugly. Everything works, but without Anti-Aliasing... That's driving me crazy!
I tried to use painter.setRenderHint(QtGui.Painter.Antialiasing, True) to enable Anti-Aliasing, but it doesn't work. I also read the C++ source code of QWebPage and QWebView, but I didn't found any useful information.
@class HTMLDelegate(QtGui.QStyledItemDelegate):
def paint(self, painter, option, index):
options = QtGui.QStyleOptionViewItemV4(option)
self.initStyleOption(options, index)style = QtGui.QApplication.style() if options.widget is None else options.widget.style() webPage = QtWebKit.QWebPage(self) webFrame = webPage.mainFrame() webFrame.setHtml(options.text) webPage.setViewportSize(webPage.mainFrame().contentsSize()) options.text = "" style.drawControl(QtGui.QStyle.CE_ItemViewItem, options, painter) textRect = style.subElementRect(QtGui.QStyle.SE_ItemViewItemText, options) painter.save() # not works #painter.setRenderHint(QtGui.Painter.Antialiasing, True) webFrame.render(painter) painter.restore()@
-
Maybe resolved. Maybe it is a Qt bug, I relogin and the problem went away :) Will remove it.