Reputation: 6213
I want to implement a window in Qt which has
That's the code I have:
// the constructor
ReplayWidget::ReplayWidget(QWidget *parent)
:QWidget(parent, Qt::WindowStaysOnTopHint)
{
m_closeButton = new QPushButton(parent);
m_closeButton->setText("Close");
m_closeButton->move(10, 10);
m_closeButton->setMinimumSize(QSize(100, 51));
m_closeButton->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
}
// the overwritten repaint-method
void ReplayWidget::paintEvent(QPaintEvent* pe)
{
QPainter painter(this);
if (m_bgImage)
{
painter.drawImage(QPoint(0, 0), *m_bgImage);
}
QWidget::paintEvent(pe);
}
Unfortunately this does not work, the image from m_bgImage appears as expected but the pushbutton is not visible.
Any idea what could be wrong here?
Upvotes: 1
Views: 108
Reputation: 4708
Add m_closeButton->show()
and replace QPushButton(parent)
with QPushButton(this)
Upvotes: 2