Setting an image as the background of th UI
-
I am trying to create an appealing UI by setting the background as an image using Qt Creator. Could someone please help me on the steps I am supposed to follow because I am stuck.
-
You could set the background brush for the widget, doing something like this:
@
QPalette myPalette = palette();
QBrush windowBrush = myPalette.window();
windowBrush.setTexture( backGroundPixmap ); // use setTextureImage if the picture is a QImage
myPalette.setBrush( QPalette::Window, windowBrush );
@I did not test this code, so there maybe it does not work just like that. Let me know if you have problems with this.
-
I dont think you git me right. I meant how do i set an image like a photo as the background of the UI?
-
[quote author="ommz" date="1338242420"]I dont think you git me right. I meant how do i set an image like a photo as the background of the UI?[/quote]
Did you even try what mkuettler proposed? It sounds reasonable.
Apart from that: No, a background image won't make any UI appealing, only cluttered and unprofessional. If that is your goal, go right ahead ;)
-
You can also check "Embedded Styles Demonstration":http://doc.qt.nokia.com/4.7-snapshot/demos-embedded-styledemo.html example.
-
Do set background image for a ui.
you need to add resoucre file in the project's floder and add the resorce file name to the .pro file
(RESOURCES +=
resource.qrc
)content of resource.qrc
<RCC>
<qresource prefix="/new/icon">
<file>imagefilename</file>
</qresource>
</RCC>then go to the ui and select change style sheet
add resource to it
background-image: url(:/filepath);