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. Maybe im to dumb, but i cant get the icons to work.
Qt 6.11 is out! See what's new in the release blog

Maybe im to dumb, but i cant get the icons to work.

Scheduled Pinned Locked Moved Solved General and Desktop
26 Posts 3 Posters 815 Views 3 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.
  • Joe von HabsburgJ Joe von Habsburg

    @Joe-von-Habsburg said in Maybe im to dumb, but i cant get the icons to work.:

    You may need to copy the “themefolder” folder to the “exe” folder. This way, you can access the file directory without using QRC. It will be easier for you.

    follow that way.

    for : resouces file add
    Right Click your project -> add new file -> qt -> qt resources file

    MSC615M Offline
    MSC615M Offline
    MSC615
    wrote last edited by
    #17

    @Joe-von-Habsburg ok, got it, qrc file is in. Now i did add prefix and typed / as prefix, should i also type something in the Lang thing and alias?

    1 Reply Last reply
    0
    • Joe von HabsburgJ Offline
      Joe von HabsburgJ Offline
      Joe von Habsburg
      wrote last edited by
      #18

      There's no need; I think you can leave it as “/” in the prefix section because you're creating subfolders within the folder.

      To reiterate, you may need to copy it into the EXE folder, or create a folder in another location—such as the Documents folder—and place it there. I’m mentioning this because users can add their own themes. This is because the resources file is compiled along with your application.

      MSC615M 1 Reply Last reply
      0
      • Joe von HabsburgJ Offline
        Joe von HabsburgJ Offline
        Joe von Habsburg
        wrote last edited by Joe von Habsburg
        #19

        I think you generally understand what you need to do. Create a folder in a location accessible to the user, check that location when the app launches, and add the themes to the combo box or another location to apply the changes.

        The QRC file is necessary for this reason. If the theme folder is missing, the default theme stored there will be used. So it’s not entirely unnecessary.

        1 Reply Last reply
        0
        • Joe von HabsburgJ Joe von Habsburg

          There's no need; I think you can leave it as “/” in the prefix section because you're creating subfolders within the folder.

          To reiterate, you may need to copy it into the EXE folder, or create a folder in another location—such as the Documents folder—and place it there. I’m mentioning this because users can add their own themes. This is because the resources file is compiled along with your application.

          MSC615M Offline
          MSC615M Offline
          MSC615
          wrote last edited by
          #20

          @Joe-von-Habsburg ok, that means if people want to add their own themes, they need to edit the qrc file? or can i do like i tried to that the code recognizes new folders in the icon themes folder and uses the icons in there?(and holy frick, i need to do a lot to make it easy for others to use it. i also need to make it compatible to my Raspberry Pi 4B with frickin 1GB RAM and 3GB swap. thats gonna be a journey!

          Joe von HabsburgJ 1 Reply Last reply
          0
          • MSC615M MSC615

            @Joe-von-Habsburg ok, that means if people want to add their own themes, they need to edit the qrc file? or can i do like i tried to that the code recognizes new folders in the icon themes folder and uses the icons in there?(and holy frick, i need to do a lot to make it easy for others to use it. i also need to make it compatible to my Raspberry Pi 4B with frickin 1GB RAM and 3GB swap. thats gonna be a journey!

            Joe von HabsburgJ Offline
            Joe von HabsburgJ Offline
            Joe von Habsburg
            wrote last edited by
            #21

            @MSC615 said in Maybe im to dumb, but i cant get the icons to work.:

            hey need to edit the qrc file

            no because qrc file compiler with when your build. my opinion qrc file have to hold defult themes only. users can not change it.

            For users :
            you have to folder somewhere (documents or exe folder etc.)
            that folder has your default themes and user custom themes.

            you read path and add to combobox

            MSC615M 1 Reply Last reply
            0
            • Joe von HabsburgJ Joe von Habsburg

              @MSC615 said in Maybe im to dumb, but i cant get the icons to work.:

              hey need to edit the qrc file

              no because qrc file compiler with when your build. my opinion qrc file have to hold defult themes only. users can not change it.

              For users :
              you have to folder somewhere (documents or exe folder etc.)
              that folder has your default themes and user custom themes.

              you read path and add to combobox

              MSC615M Offline
              MSC615M Offline
              MSC615
              wrote last edited by
              #22

              @Joe-von-Habsburg ok but how do i do the displaying of custom ones than? because how should i implement them that i dont have the same problem that caused this thread to be created but with custom themes?

              SGaistS 1 Reply Last reply
              0
              • MSC615M MSC615

                @Joe-von-Habsburg ok but how do i do the displaying of custom ones than? because how should i implement them that i dont have the same problem that caused this thread to be created but with custom themes?

                SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote last edited by
                #23

                @MSC615 because you will get the absolute path to the folder containing the theme from you user.
                And if something is missing, you can use the image of the default theme to not break anything and tell the user through a message that something is wrong.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                MSC615M 1 Reply Last reply
                1
                • SGaistS SGaist

                  @MSC615 because you will get the absolute path to the folder containing the theme from you user.
                  And if something is missing, you can use the image of the default theme to not break anything and tell the user through a message that something is wrong.

                  MSC615M Offline
                  MSC615M Offline
                  MSC615
                  wrote last edited by
                  #24

                  @SGaist true, thanks. but now i dont know how to turn the code that @Joe-von-Habsburg gave me, this code:

                  void MainWindow::on_comboBox_currentTextChanged(QString text)
                  {
                      ui->spotify->setIcon(QIcon(QPixmap(QString(":/iconThemes/%1/spotify.png").arg(text)));
                      ...
                  }
                  

                  into a working version for my code, because i already have a thing to show the name of the theme and choose it:

                      // some logic to set the theme
                      connect(ui->themeComboBox, &QComboBox::currentTextChanged,
                              this, [=](const QString &theme) {
                          setTheme(theme);
                      });
                  

                  oh my god i need to learn C++ in the future!!

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote last edited by
                    #25

                    I suspect that your setTheme function is where you update all the icons, right ?
                    So it's there that you should use the example path creation.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    MSC615M 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      I suspect that your setTheme function is where you update all the icons, right ?
                      So it's there that you should use the example path creation.

                      MSC615M Offline
                      MSC615M Offline
                      MSC615
                      wrote last edited by
                      #26

                      @SGaist oooohh right. oversaw the %1 in the path. yeee gonna put something there for the user warning when i got the other things done!

                      1 Reply Last reply
                      0
                      • MSC615M MSC615 has marked this topic as solved

                      • Login

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