Hi all,
I have a custom QLabel m_opImageViewLabel which I reimplement the paintEvent for my display.
Then I have a QWidget which is used to display the Qlabel.
However, I want this QLabel to be inside the QScrollArea so that the scrollbar will appear automatically.
Below is the constructor of the QWidget.
ImageViewClient::ImageViewClient(QWidget *parent)
: QWidget(parent)
{
int size = 800;
ui.setupUi(this);
m_opImageViewLabel = new ImageViewLabel();
m_poScrollArea = new QScrollArea(this);
m_poScrollArea->setBackgroundRole(QPalette:ark);
m_poScrollArea->setMinimumSize(QSize(size,size));
m_poScrollArea->setMaximumSize(QSize(size,size));
m_poScrollArea->setWidget(m_opImageViewLabel);
this->layout()->addWidget(m_poScrollArea);
}
When I try to run this, the image does not appear in the label. The Dark background is shown instead.
But it will work if I create a QLabel directly and add it in.
QLabel* test = new QLabel();
test->setPixmap(QPixmap("c:\\testdata\\wj2.bmp"));
m_poScrollArea->setWidget(test);
Is there anything I did wrong?
Thanks
Bookmarks