Please tell me the name of this element, I need to change its color to Css =_+
-
@JonB this file is in the same folder as the project...
wrote on 20 Dec 2022, 11:46 last edited by JonB@ImmortalZot
So? Please read what I wrote:Your first two relative paths doubtless do not work because where do you think it seeks relative to? It will be the current directory at runtime, and doubtless you have no control over/do not know what this is.
That's why I wrote it....
Your "project folder" does not exist at runtime. To locate such a file at runtime, you probably want to place it somewhere relative to the executable of your program, and use QCoreApplication::applicationDirPath() to generate a full path to it.
-
@ImmortalZot
So? Please read what I wrote:Your first two relative paths doubtless do not work because where do you think it seeks relative to? It will be the current directory at runtime, and doubtless you have no control over/do not know what this is.
That's why I wrote it....
Your "project folder" does not exist at runtime. To locate such a file at runtime, you probably want to place it somewhere relative to the executable of your program, and use QCoreApplication::applicationDirPath() to generate a full path to it.
wrote on 20 Dec 2022, 12:05 last edited by ImmortalZot@JonB
and also not work ===========QFile file("Adaptic.qss");
maybe do you know how to write way?
QFile file(QApplication::applicationDirPath() + "Adaptic.qss");
I try this variant also not work -
@JonB
and also not work ===========QFile file("Adaptic.qss");
maybe do you know how to write way?
QFile file(QApplication::applicationDirPath() + "Adaptic.qss");
I try this variant also not workwrote on 20 Dec 2022, 12:25 last edited by JonB@ImmortalZot said in Please tell me the name of this element, I need to change its color to Css =_+:
QFile file(QApplication::applicationDirPath() + "Adaptic.qss");
I have answered your question. Print that value out. Is it the path to your
.qss
file? No, because you do not place that file in the same directory as your application's executable, do you? You still have it in a source directory. Find a path you can make relative to your application's executable directory to reach the file, or copy it somewhere relative to the executable directory if necessary.Alternatively --- I do not know whether this is appropriate to your situation --- bundle the
.qss
file into your Qt resources and specify the correct Qt resource file path. -
@ImmortalZot said in Please tell me the name of this element, I need to change its color to Css =_+:
QFile file(QApplication::applicationDirPath() + "Adaptic.qss");
I have answered your question. Print that value out. Is it the path to your
.qss
file? No, because you do not place that file in the same directory as your application's executable, do you? You still have it in a source directory. Find a path you can make relative to your application's executable directory to reach the file, or copy it somewhere relative to the executable directory if necessary.Alternatively --- I do not know whether this is appropriate to your situation --- bundle the
.qss
file into your Qt resources and specify the correct Qt resource file path.wrote on 20 Dec 2022, 15:57 last edited by ImmortalZot@JonB sorry for my stupidity but I still didn't solve my problem. I realized that applicationDirPath(); shows the path to the program's startup file, but how do I use it to include Adaptic.qss
like me from applicationDirPath() make the relative path
-
@JonB sorry for my stupidity but I still didn't solve my problem. I realized that applicationDirPath(); shows the path to the program's startup file, but how do I use it to include Adaptic.qss
like me from applicationDirPath() make the relative path
@ImmortalZot
Hi
Do you need it as a standalone file ?
If not, adding it to a resource file makes it very easy to load. with syntax ":/Adaptic.qss"
and it cant go away/be forgotten.Its easy to add a resource file so let me know if that would work for you.
-
@ImmortalZot
Hi
Do you need it as a standalone file ?
If not, adding it to a resource file makes it very easy to load. with syntax ":/Adaptic.qss"
and it cant go away/be forgotten.Its easy to add a resource file so let me know if that would work for you.
wrote on 21 Dec 2022, 09:06 last edited by@mrjj this option does not work, i already tried
-
@mrjj this option does not work, i already tried
@ImmortalZot If you add your style-sheet to a resource file there is absolutely no need to use QFile!
Please read https://doc.qt.io/qt-5/resources.html to learn how to use resource files. -
@ImmortalZot If you add your style-sheet to a resource file there is absolutely no need to use QFile!
Please read https://doc.qt.io/qt-5/resources.html to learn how to use resource files.wrote on 21 Dec 2022, 11:25 last edited by@jsulm thank you very much, now everything works as it should. Sorry for the stupidity, I'm just not a programmer, I'm a doctor
-
@jsulm thank you very much, now everything works as it should. Sorry for the stupidity, I'm just not a programmer, I'm a doctor
@ImmortalZot No Problem!
You should also pay attention to all these warnings. It seems like you're using the auto-connect feature to connect signals and slots. You should not do that, as it is not very reliable. Connect your signals and slots explicitly using connect(). -
@jsulm thank you very much, now everything works as it should. Sorry for the stupidity, I'm just not a programmer, I'm a doctor
wrote on 21 Dec 2022, 11:36 last edited by@ImmortalZot said in Please tell me the name of this element, I need to change its color to Css =_+:
Sorry for the stupidity, I'm just not a programmer, I'm a doctor
You should see my/our [lack of] knowledge of the body compared to your knowledge of programming! :) Thank goodness they don't ask us to try medical stuff as amateurs, the worst you can do is crash a program .... ;-)
20/20