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
{
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();
}
MyWidgetOne::MyWidgetOne(QWidget* parent): QWidget(parent)
{
int x, y;
coordOne = new QPoint;
drawLabel = new QLabel;
QPixmap dl;
dl.load("resources/image_ori.bmp");
dl = dl.copy(x-25, y-25, 50, 50);
dl.save("resources/image.bmp");
drawLabel->setPixmap(dl);
QVBoxLayout* mainLayout = new QVBoxLayout;
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();
}
To copy to clipboard, switch view to plain text mode
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.
Bookmarks