Results 1 to 20 of 26

Thread: Image processing

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Image processing

    Quote Originally Posted by aurelius View Post
    Of course, I don't know if it's even useful, but ok, I just don't have access on it.
    Not in your case. You need a plain graphicsview and QGraphicsPixmapItems.

    Do you have any qmake that it would work properly?
    Always use only the instance of qmake that comes with your installation, be it a binary or an own build originated.

    I think I will have to create my own makefiles with my own qmake, but that is a problem.
    No, you need to read a tutorial or two. Don't make things more complex than they are.

    Whatsoever, I tried to do sth with grid layout. I managed to put two images in a grid layout, so I guess I can do it for more images.
    Forget it. Read about QGraphicsView, pretty please.

  2. #2
    Join Date
    Oct 2008
    Posts
    28
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default

    Yeah I think you are right. This is what I am doing now.

    Well, I think now I have found the info I needed for the first and basic task I wanted to do: to order images one after the other in a grid. I found the drill down example which does a similar thing. Now, i would like the grid to refresh, an adjust the number of images it shows, according to the width of the window. Except for the way, with which I catch the event of resizing the window, computing the dimensions, comparing them with image dimensions and setting the new GraphicsPixmapItem coordinates, is there any automatic way for doing all these ?
    Last edited by wysota; 29th October 2008 at 22:50.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Image processing

    No, you have to modify the scene size to reflect the view's viewport size and react on scene resizes. Basically all should be done in the scene apart from resizing the scene itself.

  4. #4
    Join Date
    Oct 2008
    Posts
    28
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Image processing

    From what you saying, I understand this:

    1) I have to create a QGraphicsScene item. From all the reading I ve made, this is the class that manages all items inside the area.

    2) I have to create a QGraphicsView item. This item is for visualizing the whatever contents of QGraphicsScene.

    3) I add items in the QGraphicsScene. I use the function addPixmap. I add them to the scene and display them. However, the documentation says, that items are by default positioned to (0,0). So, if I add 2 items, the second overlaps the first. I can change the position of the item with the use of GraphicsPixmapItem->setOffset(...). What I was trying all along to find out is the following: in order to have several pixmap items in the scene, and order them into a grid, how do I define the position of the items? Is there some function that layouts them like that or I have to define myself the position of the items with setOffset() function ? That is, is there any function that says to the scene:
    "ok, put this pixmap from top to right, where there is empty space" because from what I ve read till now(and maybe because I am a beginner in GUIs), the only function I can do is "ok, put the pixmap in (0,0), if the programmer wants sth else, he will change it by himself later".

    4) I understand what you are saying with the size and stuff. What I don't understand is the following: I can define the scene rect. When I show the QGraphicsView, doesn't it show this rect ? What do you mean, that the scene size must reflect the view's size. The documentation says, that if you don't mess with QGraphicsView's sceneRect, it takes by default the rect of the QGraphicsScene, which means the one rect relfects to the other. Or not ?
    Last edited by aurelius; 30th October 2008 at 11:21.

  5. #5
    Join Date
    Oct 2008
    Posts
    28
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Image processing

    I found out, that in Q3, this operation was able to be performed with the use of Q3Canvas and tiles. Is that right?
    Last edited by aurelius; 30th October 2008 at 16:54.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Image processing

    Quote Originally Posted by aurelius View Post
    1) I have to create a QGraphicsScene item. From all the reading I ve made, this is the class that manages all items inside the area.

    2) I have to create a QGraphicsView item. This item is for visualizing the whatever contents of QGraphicsScene.
    Yes, that's more or less correct.

    I can change the position of the item with the use of GraphicsPixmapItem->setOffset(...).
    No, this is wrong. You need to use QGraphicsItem::setPos().

    What I was trying all along to find out is the following: in order to have several pixmap items in the scene, and order them into a grid, how do I define the position of the items?
    You have to set positions of each of the pixmaps in such way that each consecutive pixmap is moved to the right by the sum of widths of all previous pixmaps. When you don't have enough space left, reset the x coordinate and instead increase the y coordinate by the height of the previous row.

    I can define the scene rect. When I show the QGraphicsView, doesn't it show this rect ?
    Yes, it does.
    What do you mean, that the scene size must reflect the view's size.
    You always want to show the whole width of the scene. If you don't change the scene but reduce the size of the view that displays it, you'll get scrollbars which is probably not what you want.

    The documentation says, that if you don't mess with QGraphicsView's sceneRect, it takes by default the rect of the QGraphicsScene, which means the one rect relfects to the other. Or not ?
    Yes, but you might want to resize the view, right? The scene won't accomodate - it doesn't work both ways.
    Last edited by wysota; 30th October 2008 at 23:05.

  7. #7
    Join Date
    Oct 2008
    Posts
    28
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Image processing

    Quote Originally Posted by wysota View Post
    Yes, that's more or less correct.
    You have to set positions of each of the pixmaps in such way that each consecutive pixmap is moved to the right by the sum of widths of all previous pixmaps. When you don't have enough space left, reset the x coordinate and instead increase the y coordinate by the height of the previous row.
    This is what I was trying to say from the beginning.

    Now, I try to synchronize the size of the sceneRect with the size of the View window.

    When I catch the event for resizing the window, I resize the sceneRect as well. But it doesn't. Also, when I use the setPos, (I had already tried that), it puts the pixmaps in irrelevant places. I guess, the coordinated I give are for the sceneRect, and I want the coordinates for the view windows. For example when I say: put it to (0,0), it puts it to sceneRect's (0,0), not to the window's. Right ?

  8. #8
    Join Date
    Oct 2008
    Posts
    28
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Image processing

    Ok, I did most of what I wanted.

    The ResizeEvent is activated when you push the mouse button and then release it. If I want to activate it, when you just press the mouse button, what should I do. Should I reimplement the event ???

  9. #9
    Join Date
    Oct 2008
    Posts
    28
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Image processing

    I wanted to ask as well, why when I open the QGraphicsView window, it does'nt open it with the scrolls in the start but from the middle.

    Also, I added a hover event on the pixmaps and when i hover them, I am scaling them in order to give the feeling of slight zoom. When I leave the pixmap it returns to its original position. However, it doesn't work quite well. Theoretically, it takes its original size, but if i hover again multiple times over the same pixmap, it slightly changes slowly size. I guess this has sth to do with the accuracy of the numbers. I use double variables though, so I don't know why it's happening. Should I declare variables like qfloat etc? Will there be any difference ?
    Last edited by aurelius; 31st October 2008 at 15:06.

  10. #10
    Join Date
    Oct 2008
    Posts
    28
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Image processing

    Quote Originally Posted by aurelius View Post
    Also, I added a hover event on the pixmaps and when i hover them, I am scaling them in order to give the feeling of slight zoom. When I leave the pixmap it returns to its original position. However, it doesn't work quite well. Theoretically, it takes its original size, but if i hover again multiple times over the same pixmap, it slightly changes slowly size. I guess this has sth to do with the accuracy of the numbers. I use double variables though, so I don't know why it's happening. Should I declare variables like qfloat etc? Will there be any difference ?
    Does anyone have a clue on this please ?

Similar Threads

  1. Image processing via matrix
    By jones.79 in forum Qt Programming
    Replies: 10
    Last Post: 22nd September 2008, 00:42
  2. can Qlabel display a series of image one by one ?
    By jirach_gag in forum Qt Tools
    Replies: 3
    Last Post: 11th August 2008, 15:36
  3. Image Processing using Qt
    By danielperaza in forum Qt Programming
    Replies: 2
    Last Post: 9th March 2008, 18:15
  4. Finding marks on scanned image for alignment
    By caduel in forum Qt Programming
    Replies: 1
    Last Post: 23rd September 2007, 02:10
  5. How and when to repaint a widget ?
    By yellowmat in forum Newbie
    Replies: 7
    Last Post: 3rd April 2006, 16:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.