set background for mainwindow and set background color for widgets are coonfused in css.
-
in the qrc.
in this code the picture is not set for main window background :(this is my code in my css exactly)/*========================================*/ /* QWidget - QDialog */ QWidget , QDialog { background-color:rgb(67,67,67); } #MainWindow { background-image: url(":/myImg/1.jpg"); }
-
in the qrc.
in this code the picture is not set for main window background :(this is my code in my css exactly)/*========================================*/ /* QWidget - QDialog */ QWidget , QDialog { background-color:rgb(67,67,67); } #MainWindow { background-image: url(":/myImg/1.jpg"); }
@MhM93
then you need to prepend:
orqrc://
to your path. -
@MhM93
i don't know your qrc file, so i don't know if that path is correct.
What does the following return?qDebug() << QFile::exists(":/myImg/1.jpg");
-
Hi,
@raven-worx , thanks for reply.qDebug() << QFile::exists(":/myImg/1.jpg");
this code return true;
@m-sue : thanks for reply. I change my code to this. but the picture is not set the background in mainwindow:QWidget , QDialog { background-color:rgb(67,67,67); } #MainWindow { background: url(:/myImg/1.jpg); }
-
Hi,
@raven-worx , thanks for reply.qDebug() << QFile::exists(":/myImg/1.jpg");
this code return true;
@m-sue : thanks for reply. I change my code to this. but the picture is not set the background in mainwindow:QWidget , QDialog { background-color:rgb(67,67,67); } #MainWindow { background: url(:/myImg/1.jpg); }
@MhM93
and now pls try to set it exactly to this:QWidget , QDialog { background: rgb(67,67,67); } #MainWindow { background: url(':/myImg/1.jpg'); }
But most probably you wont see the image because you set it to the main window directly. And it's central widget is covering over it, since you also set a background color for all QWidgets.
-
really thanks @raven-worx for reply. I change the css to this:
QWidget , QDialog { background:rgb(67,67,67); } #MainWindow { background: url(:/myImg/1.jpg); }
all widget set dark, but the picture is not set in the main window background.
:( -
really thanks @raven-worx for reply. I change the css to this:
QWidget , QDialog { background:rgb(67,67,67); } #MainWindow { background: url(:/myImg/1.jpg); }
all widget set dark, but the picture is not set in the main window background.
:(@MhM93
did you read my note at the end of my last post? -
so how can I do some thong like that? I want to set back ground image for some widget and the other widget i like to be dark. How can I do that?
@MhM93
as i already said. Don't apply the background-image to the main-window but to the widget you set as central widget... -
Do you mean I set the main window central widget for set back ground image?could you give me example?
So sorry I am beginner in qt(also in English) so sorry :">@MhM93
CSS:QWidget , QDialog { background:rgb(67,67,67); } #MyCentralWidget { background: url(:/myImg/1.jpg); }
CPP:
QFrame* centralWidget = new QFrame; centralWidget->setObjectName("MyCentralWidget"); mainWindow->setCentralWidget( centralWidget );