Help showing an image as a background
I am getting started in Qt world.
Im coding an application and I want to show a screen with background and later start adding widgets on it
This is what I have so far:
//widget and background intialization
QWidget *widget = new QWidget;
QHBoxLayout *layout = new QHBoxLayout;
QPushButton *button = new QPushButton("Button");
and main method:
QApplication app(argc, argv);
QGraphicsView *view = new QGraphicsView;
Window *v = new Window;
but for some reason I cannot get the image displayed on the screen
Can you help me please??
Thanks a lot in advance!!!
Make sure that file Tapete.png exists on the correct location.
Thanks both it was a problem with paths, once I added the file to resources it worked fine :)
But now I've come accross with another two problems.
As you can see on the picture
there is a white frame surrounding the background? how can expand the image to use all the available window?
On the other hand I've added a button but it is taking same background and i don't want it. How can solve it.
I've tried creating a custom class which inherits QWidget but result is the same
[quote author="rulovic" date="1323040204"]
there is a white frame surrounding the background? how can expand the image to use all the available window?[/quote]
Have you set the "background-repeat":http://doc.qt.nokia.com/stable/stylesheet-reference.html#repeat property?
yes. I used:
@setStyleSheet("background-image: url(:/images/tapete.png);background-origin: content;background-clip: margin;");@
Somehow in above line I miss keyword @repeat@
You forgot to write it here, or you forgot to write it in your program?
I forgot to write it here, I have it in my program but the result is the same :s