Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. 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 =_+

Scheduled Pinned Locked Moved Unsolved General and Desktop
20 Posts 4 Posters 951 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    ImmortalZot
    wrote on 19 Dec 2022, 08:50 last edited by
    #1

    Please tell me the name of this element, I need to change its color to Css
    3f282faa-381c-4b86-bf1a-161735be91de-image.png

    J 1 Reply Last reply 19 Dec 2022, 08:53
    0
    • I ImmortalZot
      19 Dec 2022, 08:50

      Please tell me the name of this element, I need to change its color to Css
      3f282faa-381c-4b86-bf1a-161735be91de-image.png

      J Offline
      J Offline
      JonB
      wrote on 19 Dec 2022, 08:53 last edited by
      #2

      @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 an objectName?

      1 Reply Last reply
      0
      • I Offline
        I Offline
        ImmortalZot
        wrote on 19 Dec 2022, 09:24 last edited by
        #3

        6264bbd7-9c43-4edd-a5f1-5bd1dcfb4bfb-image.png
        thanks, i need to find the background of this element)

        J 1 Reply Last reply 19 Dec 2022, 09:26
        0
        • I ImmortalZot
          19 Dec 2022, 09:24

          6264bbd7-9c43-4edd-a5f1-5bd1dcfb4bfb-image.png
          thanks, i need to find the background of this element)

          J Offline
          J Offline
          JonB
          wrote on 19 Dec 2022, 09:26 last edited by JonB
          #4

          @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 individual QLineEdit to set its background color individually then you need to give it an objectName to use as a selector like I said.

          I 1 Reply Last reply 19 Dec 2022, 09:58
          0
          • J JonB
            19 Dec 2022, 09:26

            @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 individual QLineEdit to set its background color individually then you need to give it an objectName to use as a selector like I said.

            I Offline
            I Offline
            ImmortalZot
            wrote on 19 Dec 2022, 09:58 last edited by
            #5

            @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

            J 1 Reply Last reply 19 Dec 2022, 10:03
            0
            • I ImmortalZot
              19 Dec 2022, 09:58

              @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

              J Offline
              J Offline
              JonB
              wrote on 19 Dec 2022, 10:03 last edited by JonB
              #6

              @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 the QLineEdit rule? Have you discovered whether the elements are indeed QLineEdits? Maybe they are QLabels? Can you type into these widgets? Maybe this is a QTreeView and these are QTreeWidgetItems? 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?

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mrjj
                Lifetime Qt Champion
                wrote on 19 Dec 2022, 15:05 last edited by mrjj
                #7

                Hi
                Can it be its the alternate color ?
                and we are looking at a treewidget/view?

                QTableWidget {
                	alternate-background-color: yellow;
                 ....
                }
                
                I 1 Reply Last reply 20 Dec 2022, 10:17
                0
                • M mrjj
                  19 Dec 2022, 15:05

                  Hi
                  Can it be its the alternate color ?
                  and we are looking at a treewidget/view?

                  QTableWidget {
                  	alternate-background-color: yellow;
                   ....
                  }
                  
                  I Offline
                  I Offline
                  ImmortalZot
                  wrote on 20 Dec 2022, 10:17 last edited by
                  #8

                  @mrjj thanks also I have a problem with the relative path
                  work
                  894e70c2-f111-4edd-8279-8d79ac500dd3-image.png
                  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

                  J 1 Reply Last reply 20 Dec 2022, 10:21
                  0
                  • I ImmortalZot
                    20 Dec 2022, 10:17

                    @mrjj thanks also I have a problem with the relative path
                    work
                    894e70c2-f111-4edd-8279-8d79ac500dd3-image.png
                    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

                    J Offline
                    J Offline
                    JonB
                    wrote on 20 Dec 2022, 10:21 last edited by
                    #9

                    @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.....

                    I 1 Reply Last reply 20 Dec 2022, 11:45
                    0
                    • J JonB
                      20 Dec 2022, 10:21

                      @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.....

                      I Offline
                      I Offline
                      ImmortalZot
                      wrote on 20 Dec 2022, 11:45 last edited by
                      #10

                      @JonB this file is in the same folder as the project...

                      J 1 Reply Last reply 20 Dec 2022, 11:46
                      0
                      • I ImmortalZot
                        20 Dec 2022, 11:45

                        @JonB this file is in the same folder as the project...

                        J Offline
                        J Offline
                        JonB
                        wrote on 20 Dec 2022, 11:46 last edited by JonB
                        #11

                        @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.

                        I 1 Reply Last reply 20 Dec 2022, 12:05
                        0
                        • J JonB
                          20 Dec 2022, 11:46

                          @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.

                          I Offline
                          I Offline
                          ImmortalZot
                          wrote on 20 Dec 2022, 12:05 last edited by ImmortalZot
                          #12

                          @JonB 4a8b99fe-9bc7-4436-8f27-6b50a83e8400-image.png
                          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

                          J 1 Reply Last reply 20 Dec 2022, 12:25
                          0
                          • I ImmortalZot
                            20 Dec 2022, 12:05

                            @JonB 4a8b99fe-9bc7-4436-8f27-6b50a83e8400-image.png
                            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

                            J Offline
                            J Offline
                            JonB
                            wrote on 20 Dec 2022, 12:25 last edited by JonB
                            #13

                            @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.

                            I 1 Reply Last reply 20 Dec 2022, 15:57
                            1
                            • J JonB
                              20 Dec 2022, 12:25

                              @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.

                              I Offline
                              I Offline
                              ImmortalZot
                              wrote on 20 Dec 2022, 15:57 last edited by ImmortalZot
                              #14

                              @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
                              97591436-0f36-499f-a908-1fdc21f20db8-image.png

                              M 1 Reply Last reply 20 Dec 2022, 16:30
                              0
                              • I ImmortalZot
                                20 Dec 2022, 15:57

                                @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
                                97591436-0f36-499f-a908-1fdc21f20db8-image.png

                                M Offline
                                M Offline
                                mrjj
                                Lifetime Qt Champion
                                wrote on 20 Dec 2022, 16:30 last edited by mrjj
                                #15

                                @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.

                                I 1 Reply Last reply 21 Dec 2022, 09:06
                                0
                                • M mrjj
                                  20 Dec 2022, 16:30

                                  @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.

                                  I Offline
                                  I Offline
                                  ImmortalZot
                                  wrote on 21 Dec 2022, 09:06 last edited by
                                  #16

                                  @mrjj this option does not work, i already tried
                                  7c108606-b7ee-469b-a068-5085a58a6534-image.png

                                  jsulmJ 1 Reply Last reply 21 Dec 2022, 09:30
                                  0
                                  • I ImmortalZot
                                    21 Dec 2022, 09:06

                                    @mrjj this option does not work, i already tried
                                    7c108606-b7ee-469b-a068-5085a58a6534-image.png

                                    jsulmJ Offline
                                    jsulmJ Offline
                                    jsulm
                                    Lifetime Qt Champion
                                    wrote on 21 Dec 2022, 09:30 last edited by
                                    #17

                                    @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.

                                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    I 1 Reply Last reply 21 Dec 2022, 11:25
                                    2
                                    • jsulmJ jsulm
                                      21 Dec 2022, 09:30

                                      @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.

                                      I Offline
                                      I Offline
                                      ImmortalZot
                                      wrote on 21 Dec 2022, 11:25 last edited by
                                      #18

                                      @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

                                      jsulmJ J 2 Replies Last reply 21 Dec 2022, 11:27
                                      0
                                      • I ImmortalZot
                                        21 Dec 2022, 11:25

                                        @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

                                        jsulmJ Offline
                                        jsulmJ Offline
                                        jsulm
                                        Lifetime Qt Champion
                                        wrote on 21 Dec 2022, 11:27 last edited by
                                        #19

                                        @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().

                                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                                        1 Reply Last reply
                                        0
                                        • I ImmortalZot
                                          21 Dec 2022, 11:25

                                          @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

                                          J Offline
                                          J Offline
                                          JonB
                                          wrote on 21 Dec 2022, 11:36 last edited by
                                          #20

                                          @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 .... ;-)

                                          1 Reply Last reply
                                          0

                                          6/20

                                          19 Dec 2022, 10:03

                                          14 unread
                                          • Login

                                          • Login or register to search.
                                          6 out of 20
                                          • First post
                                            6/20
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved