PDA

View Full Version : setting a window background...



nupul
10th April 2006, 05:20
How can you set the widow background of the app window to any image format supported by Qt.

Eg...say I am using a List View...and wish that the contents are displayed in the window with the background set to say "ship.jpg" rather than the usual white space?

Similarly is it also possible to tile a "background image" horizontally along the length of a toolbar or a popup menu?

Also I have seen in windows explorer (Xp Pro) that there is a water mark present at the bottom right of the window....can i achieve the same with Qt?

I'd appreciate a sample code if possible...

Thanks

Nupul

zlatko
10th April 2006, 08:08
For set window background use void QWidget::setPaletteBackgroundColor ( const QColor & ) [virtual]

nupul
10th April 2006, 08:37
For set window background use void QWidget::setPaletteBackgroundColor ( const QColor & ) [virtual]

I am aware of this function - it existed in Qt3 and am using Qt4...I can't figure out how to set the background to a *.jpg...how can i use the above function for this!!!

thanks

jpn
10th April 2006, 08:51
QBrush brush(QPixmap("bg.jpg"));
QPalette palette = view->palette();
palette.setBrush(QPalette::Base, brush);
view->setPalette(palette);

zlatko
10th April 2006, 08:52
Well try create palette with needed picture brush...And use setPalette() for your widget...
And just remark : have you try use QDesigner for set background image?

nupul
10th April 2006, 09:07
And just remark : have you try use QDesigner for set background image?


No. Why? Does it have any benefit?

nupul
10th April 2006, 09:10
well jpn, thanks for the reply...I had gone over that particular section in the doc but missed the mention of "customPattern (Pixmap)" at the bottom right of the image....perception of image problems :p

Thanks.

Nupul

zlatko
10th April 2006, 09:11
No. Why? Does it have any benefit?
Em..for me yes its very big benefit...Why i must do it by own coding if i can just set it from QDesigner :p ..Think about it ;)

Code less create more :)

nupul
10th April 2006, 09:41
Em..for me yes its very big benefit...Why i must do it by own coding if i can just set it from QDesigner :p ..Think about it ;)

Code less create more :)


This is the obvious benefit....i just wanted to know if there was anything more to it :p

Thanks

nupul

zlatko
10th April 2006, 09:45
This is the obvious benefit....i just wanted to know if there was anything more to it :p

Thanks

nupul

No only your time keeping ;)

wysota
10th April 2006, 09:54
This is the obvious benefit....i just wanted to know if there was anything more to it :p

You can learn from the code it generates to see how should things be done properly.