hi
how to make a image as a background for mainwindow.
hi
how to make a image as a background for mainwindow.
And an extra question:
My main screen is a QWidget. I can set the background image with a style sheet containing the following:
Qt Code:
QWidget#myMainWindow { background-image: url(../data/my_background.png); }To copy to clipboard, switch view to plain text mode
The trouble is that my main window has a geometry of 0,0,1024,768, which matches the dimensions of the background image. However, if the user re-sizes the window to larger than that, the background image tiles to fill the background. This is visually ugly.
What I want is for the background image to automatically scale itself, like a QLabel with the ScaledContents flag set to True.
So far I have failed to find any way of doing this. I even tried making a huge QLabel in the background, but could not force Qt Designer to place buttons and things on top of the QLabel.
Is there any way to make an automatically scaling background?
hi
i have tried changing background color using style sheets and it works
Qt Code:
this->setStyleSheet("background-color:red");To copy to clipboard, switch view to plain text mode
if i try to change background image it does not work
Qt Code:
this->setStyleSheet("background-image: url(:/icon/wave.png)");//does not workTo copy to clipboard, switch view to plain text mode
or
Qt Code:
this->setStyleSheet("QWidget{background-image: url(:/icon/wave.png)}");//does not workTo copy to clipboard, switch view to plain text mode
For QWidget and QDialog you should reimplement paintEvent() and do your image painting there as I remember
C++ & AMD forever
I'm not very sure. But try like
qApp->setStyleSheet("QWidget{background-image: url(:/icon/wave.png)}");
Hope it ll work.
Cheers,
Phillip
--- Please post the solution you got to solve your problem. It may help others.
Bookmarks