Results 1 to 9 of 9

Thread: Problem with QScrollArea updating from 4.0.1 to 4.1.0

  1. #1
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Unhappy Problem with QScrollArea updating from 4.0.1 to 4.1.0

    Hi all. I downloaded the last version of Qt (4.1.0) for Windows. I'm using windows XP. Before, I was using 4.0.1 version, so I thought that wouldn't exist problems updating my program to the new version. But I'm really worried, because the scroll area that I was using don't works and with version 4.0.1 worked perfectly. Well,this is what I do in the program: I have subclassed QScrollArea and I have reimplemented the method paintEvent to resize the widget that contains the scroll area since the size of the viewport and the size of the image that I draw on the widget. With version 4.0.1 the paintEvent method was called everytime the size of the main window changes, so the widget of the scroll area was ever updated. But my surpise comes when, with the new version, the paintEvent method is not called if I resize the main window. Very strange and annoying. Moreover if I call viewport() method in the paintEvent to know the size of the viewport, it give me invalid values. I have readed the list of changes of the new version but I havent' found anything changed in QScrollArea Could the problem come because I have subclased too the paintEvent method of the widget that contains the scrollarea? I repeat that the same code worked perfectly with the version before (4.0.1). But I have to use the new version because it has fixed some bugs that I need; for example saving jpegs in different quality factors and others. Anyone could explain me why it doesn't work now or what's the difference between the old QScrolArea and the new? Many thanks.
    Last edited by SkripT; 27th January 2006 at 00:57.

  2. #2
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with QScrollArea updating from 4.0.1 to 4.1.0

    Shouldn't you be overriding the paintEvent of the QScrollArea widget?

  3. #3
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with QScrollArea updating from 4.0.1 to 4.1.0

    Do you mean if I have reimplemented the paintEvent method of the scroll area? yes because I need do it

  4. #4
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with QScrollArea updating from 4.0.1 to 4.1.0

    I still need help. Has Anybody experimented the same or a similar problem with this new version or knows how to solve it? The thing is that is very frustrating to see that a thing that with version 4.0 works perfectly now with just version 4.1 doesn't
    Last edited by SkripT; 28th January 2006 at 11:50.

  5. #5
    Join Date
    Jan 2006
    Posts
    109
    Thanks
    2
    Thanked 5 Times in 5 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Problem with QScrollArea updating from 4.0.1 to 4.1.0

    I understand it can be frustrating, but you're maybe using the API in a way that results in undefined behavior (works in Qt 4.0 by mere luck, doesn't work in Qt 4.1).

    A minimal compilable example that reproduces the problem would help here.

  6. #6
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with QScrollArea updating from 4.0.1 to 4.1.0

    Well, I comment with more details the problems that I have noticed with the scroll area of this new version (4.1.0). I have subclassed QScrollArea because I need to reimplement the method paintEvent. I put an instance of this class as a central widget of a main window. I want that the first time that appears the main window is in full screen, calling QMainWindow::setWindowState(Qt::WindowMaximized). Well, I subclass QWidget because i want to paint under the widget a image with qpainter on the paint event of the iwdget. I put this widget inside the scroll area with ScrollArea::setWidget method. And here comes the main problem: the paintEvent of the scroll area only is called the first time the scroll area is shown: if I try to resize the main window, the paint event of the scroll area is not called while in version 4.0.1 was called everytime I resized the main window. I find it very strange . For example if i put the next code in the paintEvent of the scroll area:

    Qt Code:
    1. void FotoAreaEditorFotos::paintEvent(QPaintEvent *event)
    2. {
    3. FotoEditorFotos *foto = widget();
    4.  
    5. if (foto)
    6. foto -> resize(viewport() -> width(), viewport() -> height());
    7. }
    To copy to clipboard, switch view to plain text mode 

    "FotoAreaEditorFotos" is my subclass of "QScrollArea" and "FotoEditorFotos" is the widget that i insert in the scroll area. I have reimplemented the functions widget() and setWidget() of my scroll area to only permit insert and return instances of "FotoEditorFotos" class.
    The rersult of this example code should resize the widget that manages the scroll area to the viewport's size everytime the paint event is called. So, in theory, if i resize the main window, the paint event method has to be called and, so, the widget of the scroll area should be resized to the new viewport's size. Well in the partice, the result of this code is that the widget is resized only the first time: when I try to reduce the size of the main window (the first time is shown at full screen), appears the scroll bars on the scroll area meaning that the widget has not been resized to new viewport's size.

    I hope this time all this explanation could help to find my problem. Thanks.
    Last edited by SkripT; 28th January 2006 at 22:01.

  7. #7
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with QScrollArea updating from 4.0.1 to 4.1.0

    Why aren't you using the resize event instead of the paint event?

    It looks like you are really trying to respond to resizes, so use the resize event. There is no guarantee that the paintEvent will be called unless you expose new areas of a widget (by resizing larger, or moving something that overlaps the widget), so you should not be relying on the paintEvent to track resizes.

    [Of course I may be misunderstanding what you are trying to do here.]

  8. #8
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with QScrollArea updating from 4.0.1 to 4.1.0

    Hi Chicken Blood Machine (great name ) I think that this event could help, I'm gonna try it. I didn't knew that exist this event that's why I made it in the paintEvent ...

  9. #9
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with QScrollArea updating from 4.0.1 to 4.1.0

    It works!!!!!!!!! Simply i have changed the paintEvent for resizeEvent . I dont' understand why it worked in the previous version ... Thanks
    Last edited by SkripT; 28th January 2006 at 22:47.

Similar Threads

  1. Replies: 2
    Last Post: 8th October 2006, 20:14

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.