Is Update() the right way?
Hi all,
I have a program in which two widgets are connected together. One widget displays an image and upon a mouse event (press) it passes the co-ordinates (in the form of a QPoint) to the other widget. My hope is that this Widget then displays a cropped version of the other image.
I have so far been unsuccessful in this. My main problem is updating the cropped-image display widget. Currently it shows nothing (the signals and slots are working by the way).
Here is the code
Code:
{
int x, y;
dl.load("resources/image_ori.bmp");
dl = dl.copy(x-25, y-25, 50, 50);
dl.save("resources/image.bmp");
drawLabel->setPixmap(dl);
mainLayout->addWidget(drawLabel);
setLayout(mainLayout);
setWindowTitle(tr("Receiver"));
}
void MyWidgetOne
::showCoords(QPoint xy
) {
int i, j;
coordOne = &xy;
i = (coordOne->x());
j = coordOne->y();
x = i;
y = j;
update();
//repaint();
}
So as you can see I use x and y to define the corner of the area to be displayed (with a 50 height and width). When I receive the QPoint, I update this values via i and j).
I thought putting update() or repaint() would work but they have so far been of no use. Any help would be appreciated.
Re: Is Update() the right way?
Hey,
Managed to get it working.
Code:
{
dm.load("resources/image_ori.bmp");
dm = dm.copy(x-25, y-25, 50, 50);
dm.save("resources/image.bmp");
drawLabel->setPixmap(dm);
}
Forgot to include the above :o I suppose just writing down the problem reminded me of what was missing!