I can see some people have read my previous message but they have not answered. Is there any detail I'm forgotting to get an answer to my problem? Any help is very welcome. Thanks!
I can see some people have read my previous message but they have not answered. Is there any detail I'm forgotting to get an answer to my problem? Any help is very welcome. Thanks!
Last edited by TeresaML; 22nd November 2009 at 12:21.
hi.
please see the ImageViewer in the section of Widgets example. the example show how display an image, and provide very basics zooming and scaling function.
the link -- http://doc.trolltech.com/4.5/widgets-imageviewer.html
hope you find this useful.
Thank very much you for your answer. I had already seen this page and I think that I don't use this example as reference but since it uses QMainWindow and QPixmap, and I use QDialog and QImage, so it's a little bit different to implement. I think it is not interesting to me...
Thank you again for the answer, and as I have said before, any help is welcome.
QImage is designed and optimized for I/O, and for direct pixel access and manipulation, while QPixmap is designed and optimized for showing images on screen.
why need show a QImage?, when QPixmap is better choice for you needs.
please post some source code, maybe i am wrong and QImage is a better choice in your case
Hi,
I've created a function called "open()" for opening an image file and loading in a two differents frames (one for representing the original image and the other one for making some changes in it, like scale it).
void GUI:pen()
{
QString fileName=QFileDialog::getOpenFileName(this,tr("Ope n File"), QDir::currentPath());
if (!fileName.isEmpty())
{
ui.frame->image.load(fileName);
ui.frame_2->image.load(fileName);
}
}
For representing the images I've used a paintEvent function:
MiQFrame::MiQFrame(QWidget *parent) : QFrame(parent)
{
}
void MiQFrame:aintEvent(QPaintEvent *event)
{
QPainter* p;
p = new QPainter(this);
image = image.scaled(this->size());
p->drawImage(QPoint(0,0),image);
update();
}
At last, for scaling the second image represented in the second frame:
void GUI::zoomin()
{
ui.frame_2->image.scaled(120,120);
update();
}
I forgot to comment that I've used QPushButtons:
QObject::connect(openButton, SIGNAL(clicked()), GUIClass, SLOT(open()));
QObject::connect(zoominButton, SIGNAL(clicked()), open2Class, SLOT(zoomin()));
Note that image.scaled() does not scale the image, it returns a scaled copy of it.
Could you give more details, please? any solution?
soemthing like -
scaledImage = image.scaled(200,200); // scaled returns a copy which you need to assign. It wont alter the original image.
Hope you get the point![]()
What does it happen when update() is used in PainEvent?
In my case, I've detected that if I don't put Update() image isn't represented in the frame...
Last edited by TeresaML; 25th November 2009 at 11:23.
There is no need to call update() in an Paint Event .
The paintEvent() method is called automatically when:
Your widget is shown for the first time.
After a window has been moved to reveal some part (or all) of the widget.
The window in which the widget lies is restored after being minimized.
The window in which the widget lies is resized.
The user switches from another desktop to the desktop on which the widget's window lies.
What you can do from the paint event is to call a member function which will do the scaling of your image and will return the image in the paint event.
Bookmarks