Maybe im to dumb, but i cant get the icons to work.
-
@MSC615 said in Maybe im to dumb, but i cant get the icons to work.:
i dont know what you meant and how i add the recources.grc(or what it is) file
If you read
@Joe-von-Habsburg said in Maybe im to dumb, but i cant get the icons to work.:
o do this, you first need to add a resources file to your project
I told step by step.
I'm not quite sure what you mean by “changable icons.” Do you want to change the icon itself, or the button color?
If you want to change the icon, you'll need to upload your images to the xxx.qrc file, just as I explained above.
After uploading your photos as described above, here’s what you need to do.
void MainWindow::on_comboBox_currentIndexChanged(int index) { if(index == 0){ ui->spotify->setIcon(QIcon(QPixmap(":/Resources/images/spotify_black.png")); } else if (index == 1){ ui->spotify->setIcon(QIcon(QPixmap(":/Resources/images/spotify_red.png")); } ... }you need "xxx.qrc" file
If you want to change only button color, same steps
void MainWindow::on_comboBox_currentIndexChanged(int index) { if(index == 0){ ui->spotify->setStyleSheets("background-color:black;"); } else if (index == 1){ ui->spotify->setStyleSheets("background-color:red;"); } ... }If you change icon color. I do not know how it is work in qt. Maybe SVG module helps
@Joe-von-Habsburg said in Maybe im to dumb, but i cant get the icons to work.:
'm not quite sure what you mean by “changable icons.”
with that i meant changable icons, like icon themes but with custom icons. im planning to go with two themes, and other users can simply create their own and paste them i the iconTheme folder.
-
I still do not understan what you want.
Do you want like that ?

If it is, you need add black and red icon together.
If you want to change ICON COLOR, i do not know how, please look SVG module. Maybe help you -
I still do not understan what you want.
Do you want like that ?

If it is, you need add black and red icon together.
If you want to change ICON COLOR, i do not know how, please look SVG module. Maybe help you@Joe-von-Habsburg no, i have like a icon for the recorder app(only a example) in the Nothing Phone style, and one in (this is my plan) Murder drones style. it doesnt only change some colors, it also adds new things like a gliched-out-organic-fleshy-ripped-arm-thingy (typical Murder drones stuff) that grabs a bar of the icon
( thats the Nothing styled icon, needed to convert it do png to upload) and therefore the bar is a bit of and rotated to the side or completly ripped out(i know a lot of text, i didnt know how to describe it else). thats what i planned. the icon theme folders are located in the project folder and have the path(after the folder that contains other things that i might add as icons or other things) /rpimp3/iconThemes and currently there are these icon theme folders(the second is currently empty because im ass at designing murder drones stuff) : NothingTheme and MDTheme. a bit confusing how i explained it i think, but take some time understanding my sometimes random gibberish to know what i mean. -
You have iconThemes folder.
In the iconThemes you have NothingTheme folder.
NothingTheme folder has icons.there is ok.
iconThemes can be has ABCTheme folder.
and ABCTheme folder has same icons but different styles.If I understand true. You want to like that ?
now You say :
1 - I want to change theme. when theme change icon change.
2 - User can add own icon theme folder.Solution for Question 1 :
add icon to xxx.qrc file
void MainWindow::on_comboBox_currentTextChanged(QString text) { ui->spotify->setIcon(QIcon(QPixmap(QString(":/iconThemes/%1/spotify.png").arg(text))); ... }That must be work.
Solution for Question 2 :
you need list in iconThemes folder folders. and add to combox on start. also custom themes folder have to have icons with same name.
NOTE :
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. -
You have iconThemes folder.
In the iconThemes you have NothingTheme folder.
NothingTheme folder has icons.there is ok.
iconThemes can be has ABCTheme folder.
and ABCTheme folder has same icons but different styles.If I understand true. You want to like that ?
now You say :
1 - I want to change theme. when theme change icon change.
2 - User can add own icon theme folder.Solution for Question 1 :
add icon to xxx.qrc file
void MainWindow::on_comboBox_currentTextChanged(QString text) { ui->spotify->setIcon(QIcon(QPixmap(QString(":/iconThemes/%1/spotify.png").arg(text))); ... }That must be work.
Solution for Question 2 :
you need list in iconThemes folder folders. and add to combox on start. also custom themes folder have to have icons with same name.
NOTE :
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. -
You have iconThemes folder.
In the iconThemes you have NothingTheme folder.
NothingTheme folder has icons.there is ok.
iconThemes can be has ABCTheme folder.
and ABCTheme folder has same icons but different styles.If I understand true. You want to like that ?
now You say :
1 - I want to change theme. when theme change icon change.
2 - User can add own icon theme folder.Solution for Question 1 :
add icon to xxx.qrc file
void MainWindow::on_comboBox_currentTextChanged(QString text) { ui->spotify->setIcon(QIcon(QPixmap(QString(":/iconThemes/%1/spotify.png").arg(text))); ... }That must be work.
Solution for Question 2 :
you need list in iconThemes folder folders. and add to combox on start. also custom themes folder have to have icons with same name.
NOTE :
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.@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 -
@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@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?
-
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.
-
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.
-
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.
@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-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!
@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
-
@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
@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?
-
@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?
@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. -
@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.@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!!
-
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. -
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. -
M MSC615 has marked this topic as solved