Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 5

Qt-interest Archive, April 2007
GUI drawing corruption problem


Message 1 in thread

Hi,


In my first foray into the QtGUI classes I've run into a problem: I'm
trying to use QSplashscreen to create a... splash screen.. However, I
want mind to have a progress bar at the bottom.

This is what I've done:

1) Subclassed QSplashScreen, and overridden drawContents.

2) added a QProgressBar member to my subclass.

3) In drawContents, I call the appropriate methods to update the
progress bar.

4) The first time drawContents is called, I move the progress bar to the
bottom of the slashscreen. For this I use setGeometry. This moves the
progress to the bottom of the splash screen and resizes it to the right
width. (I do this in drawCOntents since the rect() method returns an
invalid QRect in the constructor - I guess the window hasn't been
created yet...)


The problem is that when the pogress bar moves to the bottom of the
splasgh screen, it seems to take the pixmap background with it. See
attached image for explination (please excuse my lack of drawing
skills).

I've tried everything I can think of, including:

* Using the painter to blank that part of the window with a white
rectangle before calling m_progressbar.update() (tried blanking the
entire window too).

* explicitly redrawing the pixmap before drawing the progress bar.

It seems to me like the Widget still thinks it's at the top of the
screen, and is grabbing the wrong part of the pixmap. How can I tell it
otherwise?


Thanks,

-- 
 [ signature omitted ] 

Attachment: splash-problem.png
Description: splash-problem.png


Message 2 in thread

Hi Thomas,

Thomas Richards escribió:
> Hi,
>
>
> In my first foray into the QtGUI classes I've run into a problem: I'm
> trying to use QSplashscreen to create a... splash screen.. However, I
> want mind to have a progress bar at the bottom.
>
> This is what I've done:
>
> 1) Subclassed QSplashScreen, and overridden drawContents.
>
> 2) added a QProgressBar member to my subclass.
>
> 3) In drawContents, I call the appropriate methods to update the
> progress bar.
>
> 4) The first time drawContents is called, I move the progress bar to the
> bottom of the slashscreen. For this I use setGeometry. This moves the
> progress to the bottom of the splash screen and resizes it to the right
> width. (I do this in drawCOntents since the rect() method returns an
> invalid QRect in the constructor - I guess the window hasn't been
> created yet...)
>
>
> The problem is that when the pogress bar moves to the bottom of the
> splasgh screen, it seems to take the pixmap background with it. See
> attached image for explination (please excuse my lack of drawing
> skills).
>
> I've tried everything I can think of, including:
>
> * Using the painter to blank that part of the window with a white
> rectangle before calling m_progressbar.update() (tried blanking the
> entire window too).
>
> * explicitly redrawing the pixmap before drawing the progress bar.
>
> It seems to me like the Widget still thinks it's at the top of the
> screen, and is grabbing the wrong part of the pixmap. How can I tell it
> otherwise?
>
>   
Try QWidget::setBackgroundOrigin*.* Anyway, you don't say if you are 
using qt 4.x or qt 3.x

Javier

--
 [ signature omitted ] 

Message 3 in thread

> Try QWidget::setBackgroundOrigin*.* Anyway, you don't say if you are
> using qt 4.x or qt 3.x
> 


Ooops! QT 4.2.2
BEGIN:VCARD
BEGIN:VCARD
VERSION:2.1
N:Richards;Thomas
FN:Thomas Richards
EMAIL;PREF;INTERNET:thomas.richards@xxxxxxxxx
REV:20070226T164514Z
END:VCARD

Message 4 in thread

Thomas Richards escribió:
>> Try QWidget::setBackgroundOrigin*.* Anyway, you don't say if you are
>> using qt 4.x or qt 3.x
>>
>>     
>
>
> Ooops! QT 4.2.2
>   
Docs says: "If no explicit background role is set, the widget inherts 
its parent widget's background role."
I'm not an expert on Qt 4 but I think you need to set the background 
role of your qprogressbar. A quick look at QWidget::setBackgroundRole 
makes me suppose that it's what you need to set up.

Hope this helps you.

Javier

--
 [ signature omitted ] 

Message 5 in thread

> Docs says: "If no explicit background role is set, the widget inherts
> its parent widget's background role."
> I'm not an expert on Qt 4 but I think you need to set the background
> role of your qprogressbar. A quick look at QWidget::setBackgroundRole
> makes me suppose that it's what you need to set up.

I added:

m_progressBar.setBackgroundRole(QPalette::Base);

And exactly the same problem occurs..

Changing the color role I pass seems to have no effect..

--
 [ signature omitted ] 

Message 6 in thread

Fixed:


The solution was to do this:

QPalette p;
p.setColor(m_progressBar.backgroundRole(), Qt::white);
m_progressBar.setPalette(p);


The answer was tucked away in the "QT 3 support members for QWidget" section.


Thanks,
BEGIN:VCARD
BEGIN:VCARD
VERSION:2.1
N:Richards;Thomas
FN:Thomas Richards
EMAIL;PREF;INTERNET:thomas.richards@xxxxxxxxx
REV:20070226T164514Z
END:VCARD