Please tell me the name of this element, I need to change its color to Css =_+
-
Please tell me the name of this element, I need to change its color to Css
-
Please tell me the name of this element, I need to change its color to Css
@ImmortalZot
Hello and welcome.People don't know what you might have "named" that element. It looks like its type is
QLineEdit
? Did you give it anobjectName
? -
thanks, i need to find the background of this element) -
thanks, i need to find the background of this element)@ImmortalZot
Not sure what relevance your pasting the CSS has. I don't know what you mean by "find" in "find the background of this element". If you need to address an individualQLineEdit
to set its background color individually then you need to give it anobjectName
to use as a selector like I said. -
@ImmortalZot
Not sure what relevance your pasting the CSS has. I don't know what you mean by "find" in "find the background of this element". If you need to address an individualQLineEdit
to set its background color individually then you need to give it anobjectName
to use as a selector like I said.@JonB this is some kind of list, it paints through one this list is generated somewhere in the code. I use a ready-made theme for my application and the problem is that I need to remove the white bg
-
@JonB this is some kind of list, it paints through one this list is generated somewhere in the code. I use a ready-made theme for my application and the problem is that I need to remove the white bg
@ImmortalZot
So you do not want to address the individual element pointed to by your arrow? It would be really helpful if you said that in response to my answers so far....So have you tried changing the
background-color
in theQLineEdit
rule? Have you discovered whether the elements are indeedQLineEdit
s? Maybe they areQLabel
s? Can you type into these widgets? Maybe this is aQTreeView
and these areQTreeWidgetItem
s? You need to do some investigation to help yourself, I don't see how we can know what widgets/items you have just by asking us? -
Hi
Can it be its the alternate color ?
and we are looking at a treewidget/view?QTableWidget { alternate-background-color: yellow; .... }
-
Hi
Can it be its the alternate color ?
and we are looking at a treewidget/view?QTableWidget { alternate-background-color: yellow; .... }
@mrjj thanks also I have a problem with the relative path
work
but if I try this way QFile file("Adaptic.qss"); ---------not work
QFile file("./Adaptic.qss"); ---------not work
QFile file(":/Adaptic.qss"); ---------not work
QFile file(":/qams/Adaptic.qss"); ---------not work -
@mrjj thanks also I have a problem with the relative path
work
but if I try this way QFile file("Adaptic.qss"); ---------not work
QFile file("./Adaptic.qss"); ---------not work
QFile file(":/Adaptic.qss"); ---------not work
QFile file(":/qams/Adaptic.qss"); ---------not work@ImmortalZot
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.I do not know about your two paths starting with
:
or what you think they address.If you write code which goes
QFile::open()
please check the result and act on it. You should always check the return result from this function..... -
@ImmortalZot
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.I do not know about your two paths starting with
:
or what you think they address.If you write code which goes
QFile::open()
please check the result and act on it. You should always check the return result from this function.....@JonB this file is in the same folder as the project...
-
@JonB this file is in the same folder as the project...
@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.
@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 work@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.@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.
@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.@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
@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 .... ;-)