gpt4 book ai didi

c++ - QPainter 未激活

转载 作者:可可西里 更新时间:2023-11-01 18:27:40 33 4
gpt4 key购买 nike

以下代码会导致一堆错误:

void MainWindow::displayBoard()
{
QPixmap pix(0,0);
pix.fill(Qt::white);
QPainter painter(&pix);
painter.setBrush(Qt::black);
for(int row = 0; row < 8; row++)
for(int col = 0; col < 8; col++)
painter.drawRect(row * 10, col * 10, 10, 10);
ui->label->setPixmap(pix);
}

错误:

QPainter::begin: Paint device returned engine == 0, type: 2
QPainter::setBrush: Painter not active
QPainter::drawRects: Painter not active

我该如何解决这个错误?

最佳答案

问题是,正如 Colin 指出的那样,pix 的大小为零。

关于c++ - QPainter 未激活,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4341707/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com