Help showing an image as a background
-
Hi all:
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;
widget->setStyleSheet("background-image: url(Tapete.png)");
//widget->setGeometry(QRect(100,100,128,128));
QHBoxLayout *layout = new QHBoxLayout;
QPushButton *button = new QPushButton("Button");
layout->addWidget(button);
bck->setLayout(layout);
addWidget(bck);
@and main method:
@
QApplication app(argc, argv);
QGraphicsView *view = new QGraphicsView;
Window *v = new Window;
view->setScene(v);
view->show();
return app.exec();
@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.
-
Hi:
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
!http://img23.imageshack.us/img23/1511/imageyhj.jpg/(image)!
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?