Magu
10th March 2010, 12:32
Hi all,
I´m trying to do some simple Qt experiments... like load and manipulate pixmaps.
Why this piece of code does not work?
image = QImage(256, 256, QImage::Format_RGB32);
QRgb value;
value = qRgb(189, 149, 39); // 0xffbd9527
image.setPixel(1, 1, value);
value = qRgb(122, 163, 39); // 0xff7aa327
image.setPixel(0, 1, value);
image.setPixel(1, 0, value);
value = qRgb(237, 187, 51); // 0xffedba31
image.setPixel(2, 1, value);
pixmap.fromImage(image,Qt::ColorOnly);
ui.label->setPixmap(pixmap);
As you can see, is a part of one example from Qt Image documentation. This code is placed in a slot, and it is connected to a button (or not, it is not important).
I only want to load and show a pixmap when the button has been pressed, at least as a first approx.
Now i´m reading something related to paint Events, and maybe this is the way to manipulate pixmap, but i have no much time.
Thanks
I´m trying to do some simple Qt experiments... like load and manipulate pixmaps.
Why this piece of code does not work?
image = QImage(256, 256, QImage::Format_RGB32);
QRgb value;
value = qRgb(189, 149, 39); // 0xffbd9527
image.setPixel(1, 1, value);
value = qRgb(122, 163, 39); // 0xff7aa327
image.setPixel(0, 1, value);
image.setPixel(1, 0, value);
value = qRgb(237, 187, 51); // 0xffedba31
image.setPixel(2, 1, value);
pixmap.fromImage(image,Qt::ColorOnly);
ui.label->setPixmap(pixmap);
As you can see, is a part of one example from Qt Image documentation. This code is placed in a slot, and it is connected to a button (or not, it is not important).
I only want to load and show a pixmap when the button has been pressed, at least as a first approx.
Now i´m reading something related to paint Events, and maybe this is the way to manipulate pixmap, but i have no much time.
Thanks