【发布时间】:2015-09-21 17:04:24
【问题描述】:
我的代码是:但是我在QWidget中找不到图片。如果我想显示图像,我该怎么办?我的代码有什么问题?
QTtest::QTtest(QWidget *parent)
: QWidget(parent)
{
QHBoxLayout * m_viewLayout = new QHBoxLayout();
this->setLayout(m_viewLayout);
QHBoxLayout * showLayout = new QHBoxLayout();
QHBoxLayout * btnLayout = new QHBoxLayout();
m_viewLayout->addLayout(showLayout);
m_viewLayout->addLayout(btnLayout);
widget1 = new QWidget();
showLayout->addWidget(widget1);
QPixmap image("C:\\Users\\zhq\\Desktop\\1.png");
QPainter painter(widget1);
painter.drawPixmap(QPoint(0,0),image);
widget2 = new QWidget();
showLayout->addWidget(widget2);
QPushButton * btn = new QPushButton("btn");
btnLayout->addWidget(btn);
showLayout->addStretch();
}
【问题讨论】: