tags:

views:

30

answers:

1

Hi, I'm developing an image viewer, based on a QScrollArea and a QLabel that contains the image to show.

Now, I need to show text over the label, like the current mouse (x,y) position, image size, etc., in a specific point, but it can't be affected by the scrolling.

How can I do this?

+1  A: 

The first thing I would try is:

container = new QWidget();
scrollArea = new QScrollArea(container);
pic = new QLabel();
pic->setPixmap(...);
scrollArea->setWidget(pic);
infoLabel = new QLabel("mouse is at 0, 0", container);
infoLabel->move(20, 20); // the desired non-scrolling position
Stefan Monov
Thanks Stefan, with your help I come up with creating an instance of the "infoLabel" in the constructor of my subclassed QScrollArea, and used the constructor infoLabel = new QLabel(viewPort());, then, in the mouse handling methods, I just set infoLabel->setText("some text"); and infoLabel->adjustSize(); to adapt the label to its contents.
Leonardo M. ramé