Hi wysota, I got it... I used grabWidget to get the image defined in QPixmap
Thanks...
Hi wysota, I got it... I used grabWidget to get the image defined in QPixmap
Thanks...
Why not inherit QLabel instead of QWidget and just get the pixmap?
Or even access the image directly as you have it stored as a class member.
Last edited by wysota; 27th March 2007 at 12:03.
I meant to not use grabWidget to get the image as you already have it. Why duplicate it?
The m_pm pixmap is the image in one window where I move the mouse. Then in other window 'zoomWindow', the area of the mouse pointer covered is shown. For this I need to have a part of m_pm pixmap only. This part is basically the 'pasteRect'
I used grabwidget to get that part 'pasteRect' of area from m_pm.
If still I'm wrong anywhere, please correct me. If possible with modification in above code.
I'll be thankful to you.
Thanks
Example attached. Scaling needs a little more work, as it ignores margins now (which causes garbage or doesn't allow to see all the image).
The code is for Qt4, although it should work with Qt3 as well. Just change the included files and the painter scaling and translating code.
vermarajeev (28th March 2007)
Hi wysota, thanks once again.
I saw the example program. I was unable to see the ouput coz of this function
Qt Code:
void buildImage() { int w = qMax(m_pt.x()-(width()/2), 0); int h = qMax(m_pt.y()-(height()/2), 0); img = px->copy(w, h, width(), height()); }To copy to clipboard, switch view to plain text mode
What I think is (might not be correct) the logic what you have writtten and mine is almost same except that you have used eventFiler and I used mouseMoveEvent.
The major difference is in the above function. Instead of copy (which is not available in Qt3) I used grabWidget ( QWidget * widget, int x = 0, int y = 0, int w = -1, int h = -1 ), which I think is quite similar to Pixmap::copy in qt4.
The other best thing about your code was that you used label which I never cared. Anyway it was a good learning experience. Thanks a lot.
Last edited by vermarajeev; 28th March 2007 at 05:24.
Hi wysota!
I have installed qt4.2.2 on my system and is able to see the output for Example program. It looks good. Thanks!!!!
Now I should first start porting qt3.x.x to qt4.x.x. What I'l do is first take a sample helloWorld program from qt3 and port it to qt4. Then see what changes I need to make to port qt3 to qt4.
Have a great day!!!!
That's not the point, although I think my approach is better as you can "spy" on a widget that doesn't know about it.
No, it's not simmilar. You should use QImage::copy() or copyBlt().The major difference is in the above function. Instead of copy (which is not available in Qt3) I used grabWidget ( QWidget * widget, int x = 0, int y = 0, int w = -1, int h = -1 ), which I think is quite similar to Pixmap::copy in qt4.
The main difference is I'm accessing the image in question directly, whereas you're grabbing the image by redirecting a paint event.
thank you guys for the QEventFilter, i never knew about it it solved my problem.
regards.
Bookmarks