QTextEdit and setStyle
-
OK
Here is my complete code, the image bg.png exists in the directory where the app is being run but is not set as the background
@#include <QtGui>int main(int argc, char **argv)
{
QApplication app(argc, argv);QTextEdit* edit = new QTextEdit(); edit->setWindowTitle("QTextEdit Background Image"); edit->setStyleSheet("background-image: url(bg.png)"); edit->show(); return app.exec();
}@
-
-
You had committed a silly mistake in adding the image to resource file. The prefix should had been "/" but it was "/images" in your case (it is also correct but) your folder containing the image was also named as "image", so the address of image should have been "/images/images/bn.jpg". It is working fine now. I have changed the prefix to "/" from "/images". So now the valid address is "/images/bn.jpg"