Results 1 to 11 of 11

Thread: setting a window background...

  1. #1
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Exclamation setting a window background...

    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
    Last edited by nupul; 10th April 2006 at 05:33. Reason: missed out few things... ;)

  2. #2
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: setting a window background...

    For set window background use void QWidget::setPaletteBackgroundColor ( const QColor & ) [virtual]
    a life without programming is like an empty bottle

  3. #3
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Red face Re: setting a window background...

    Quote Originally Posted by zlatko
    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

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: setting a window background...

    Qt Code:
    1. QBrush brush(QPixmap("bg.jpg"));
    2. QPalette palette = view->palette();
    3. palette.setBrush(QPalette::Base, brush);
    4. view->setPalette(palette);
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  5. The following user says thank you to jpn for this useful post:

    nupul (10th April 2006)

  6. #5
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: setting a window background...

    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?
    a life without programming is like an empty bottle

  7. #6
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Exclamation Re: setting a window background...

    Quote Originally Posted by zlatko
    And just remark : have you try use QDesigner for set background image?

    No. Why? Does it have any benefit?

  8. #7
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: setting a window background...

    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

    Thanks.

    Nupul

  9. #8
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: setting a window background...

    Quote Originally Posted by nupul
    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 ..Think about it

    Code less create more
    a life without programming is like an empty bottle

  10. #9
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Talking Re: setting a window background...

    Quote Originally Posted by zlatko
    Em..for me yes its very big benefit...Why i must do it by own coding if i can just set it from QDesigner ..Think about it

    Code less create more
    This is the obvious benefit....i just wanted to know if there was anything more to it

    Thanks

    nupul

  11. #10
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: setting a window background...

    Quote Originally Posted by nupul
    This is the obvious benefit....i just wanted to know if there was anything more to it

    Thanks

    nupul
    No only your time keeping
    a life without programming is like an empty bottle

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

    Default Re: setting a window background...

    Quote Originally Posted by nupul
    This is the obvious benefit....i just wanted to know if there was anything more to it
    You can learn from the code it generates to see how should things be done properly.

Similar Threads

  1. How to set Qt window transparent?
    By montylee in forum Qt Programming
    Replies: 17
    Last Post: 24th December 2013, 20:11
  2. Window Background
    By QbelcorT in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 23rd September 2008, 06:03
  3. Background image for main window widget using css.
    By Enygma in forum Qt Programming
    Replies: 8
    Last Post: 23rd August 2007, 15:40
  4. Replies: 15
    Last Post: 23rd March 2007, 16:16
  5. Replies: 4
    Last Post: 29th March 2006, 23:44

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.