[Qt-interest] Problem with setting the top level window background picture

Jason H scorp1us at yahoo.com
Mon Feb 28 15:46:48 CET 2011


It's been a while since I've done this, and I don't have access to that code.

First I am curious as to why you get a different result on a different computer. 
Likely, it has something to do with a Qt version mismatch, or a plugin DLL 
problem.

I also think your code will (tile?) the default.jpg. Perhaps you need to have an 
overloaded resizeEvent() method which will produce the background pixmap, be it 
tiled or scaled?  Also, it seems you are erasing the background causing flicker. 
I can't remember if there is a way to turn that off in Qt, or if I am thinking 
about MFC. Looking at the 4.7 docs, most of the flags I was thinking about are 
obsoleted. But you never mentioned the Qt version...

It sounds like whatever is happening, it is using the delta as the drawing area.






________________________________
From: qiang zhang <liubingzhq at gmail.com>
To: qt-interest at trolltech.com
Sent: Mon, February 28, 2011 2:28:05 AM
Subject: [Qt-interest] Problem with setting the top level window background 
picture

Hi,

int main( int argc, char ** argv )
{
        QApplication app(argc, argv);
        QWidget w;
        w.setAutoFillBackground(true);
        QPalette palette;
        palette.setBrush(QPalette::Window, QBrush(QPixmap("./default.jpg")));
        w.setPalette(palette);
        w.show();
        return app.exec();
}

I want to use qpalette to set the background picture. As above the result is 
that the background picture just has a flicker and then turn back gray.But when 
I resize a window by dragging its top or left borders (and only  those), the 
content of the window is drawn with a slight lag, and the background picture 
appears briefly on the bottom (respectively right) side  the window, filling the 
gap created by the resizing.
The same program run on some other machine  is as expected.  I don't know why. 
Can some one help me? Thanks in advanced.



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110228/d589cb0c/attachment.html 


More information about the Qt-interest-old mailing list