miqqo
21st September 2010, 10:05
Hi Im using QLabel to display an image like bellow:
mLabel = new QLabel();
mLabel->setBackgroundRole(QPalette::Base);
mLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
mLabel->setPixmap(QPixmap::fromImage(mImage));
I would like to know the correct position of the pixmap's first top-left pixel that is draw, relevant to QLabel. How I can get this info ? I'm writing an image color picker based on mouse position and I need to know the top and left offset of the QLabel's pixmap. I've tried several methods :
mLabel->frameGeometry().x();
mLabel->frameGeometry().y();
mLabel->margin();
mLabel->indent();
mLabel->contentsMargins().top();
mLabel->contentsMargins().left();
mLabel->contentsRect();
mLabel->getContentsMargins(&left, &top, &right, &bottom);
but none of them give me the correct result :(
mLabel = new QLabel();
mLabel->setBackgroundRole(QPalette::Base);
mLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
mLabel->setPixmap(QPixmap::fromImage(mImage));
I would like to know the correct position of the pixmap's first top-left pixel that is draw, relevant to QLabel. How I can get this info ? I'm writing an image color picker based on mouse position and I need to know the top and left offset of the QLabel's pixmap. I've tried several methods :
mLabel->frameGeometry().x();
mLabel->frameGeometry().y();
mLabel->margin();
mLabel->indent();
mLabel->contentsMargins().top();
mLabel->contentsMargins().left();
mLabel->contentsRect();
mLabel->getContentsMargins(&left, &top, &right, &bottom);
but none of them give me the correct result :(