基本上,我正在尝试在无框窗口周围绘制边框。它的大小是550和407。我先创建QPainter,然后创建线条,最后尝试绘制它们。
def draw_border(self):
painter = QPainter()
painter.begin(self)
pen = QPen(QColor(255, 1, 1))
painter.setPen(pen)
left = QLine(0, 0, 0, 407)
bottom = QLine(0, 407, 550, 407)
right = QLine(550, 407, 550, 0)
painter.drawLine(left)
painter.drawLine(bottom)
painter.drawLine(right)
painter.end()
我希望有三行:左,右和底部,但是什么也没发生。
答案 0 :(得分:1)
我不知道错误在哪里,因为您没有提供MCVE,所以我只提出我的解决方案,即重用小部件的rect(),使行适应窗口的大小:< / p>
let htmlText = "<html><body> Some html string </body></html>"
guard let data = dicData.desc.data(using: String.Encoding.unicode) else { return }
let attributedText = try! NSAttributedString(data: data, options: [.documentType:NSAttributedString.DocumentType.html], documentAttributes: nil)