PDA

View Full Version : Three questions : mainwindow background image,case sensitivity and push button image



qtnewbie12
3rd August 2012, 00:32
Hello,

I have three questions
1st one :
how to put an image as the background image for an application mainwindow ? I created a folder on the application directory and I called it "images" and then I put the image on it and renamed it "image.png" then I tried this code but didn't work


MainWindow::setStyleSheet("background-image:url(:/images/image.png");


the 2nd question :
when I tried to write the following code on the header I had a problem with the case sensitivity part


signals:
void findtext(const QString & str ,qt::casesensitivity cs);

according to the book that am learning from when I write qt then "::" a list appear to me and I supposed to find on that last "casesensitivity" but that doesn't happen to me ,I mean I don't find the casesensitivity on the list.
is there a class that I should include on the header to make "casesensitivity" appear on the list or what?

the 3rd question is I created an image of a close button on photoshop and I want the close button on my application to be that image ,how to do that?
8088

spirit
3rd August 2012, 06:37
1st: I can assume that you don't use qrc, that's way Qt can't resolve resource. see The Qt Resource System (http://qt-project.org/doc/qt-4.8/resources.html).
2nd: correct spelling of the enum is Qt::CaseSensitivity enum (http://qt-project.org/doc/qt-4.8/qt.html#CaseSensitivity-enum).

qtnewbie12
3rd August 2012, 07:16
1st: I can assume that you don't use qrc, that's way Qt can't resolve resource. see The Qt Resource System (http://qt-project.org/doc/qt-4.8/resources.html).
2nd: correct spelling of the enum is Qt::CaseSensitivity enum (http://qt-project.org/doc/qt-4.8/qt.html#CaseSensitivity-enum).

Thank you ,I used qrc and now the image appear but the problem now is that the image is appearing as a tile I mean its repeating itself all over the form .How can I make it appear normally ?

spirit
3rd August 2012, 10:35
See full reference about background property (http://qt-project.org/doc/qt-4.8/stylesheet-reference.html#background). Try to set Repeat to no-repeat (http://qt-project.org/doc/qt-4.8/stylesheet-reference.html#repeat).