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 =_+
Qt 6.11 is out! See what's new in the release blog

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 3.1k Views 1 Watching
  • 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 ImmortalZot

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

    JonBJ Offline
    JonBJ Offline
    JonB
    wrote on 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
    0
    • JonBJ 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.

      I Offline
      I Offline
      ImmortalZot
      wrote on 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

      JonBJ 1 Reply Last reply
      0
      • I ImmortalZot

        @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

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on 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
        1
        • JonBJ 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.

          I Offline
          I Offline
          ImmortalZot
          wrote on 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

          mrjjM 1 Reply Last reply
          0
          • I 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
            97591436-0f36-499f-a908-1fdc21f20db8-image.png

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on 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
            0
            • mrjjM mrjj

              @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 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
              0
              • I ImmortalZot

                @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 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
                2
                • jsulmJ jsulm

                  @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 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 JonBJ 2 Replies Last reply
                  0
                  • I ImmortalZot

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

                      @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

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on 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

                      • Login

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