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

                      J 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

                        J Offline
                        J 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
                        • J 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

                          J 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

                            J Offline
                            J 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

                              16/20

                              21 Dec 2022, 09:06

                              • Login

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