Unsolved QIcon from standardpixmap
-
Hi,
i just wanted to add an icon to a pushbutton. For the icon i want to choose a standardpixmap. But i cannot find any conversion from qstyle:standardpixmap to icon.
QIcon myIcon(QStyle::SP_TitleBarMinButton);
does not work
-
http://doc.qt.io/qt-4.8/qstyle.html#standardIcon
QIcon myIcon = QStyle::standardIcon(QStyle::SP_TitleBarMinButton); -
does not work, because standardIcon is not a static member o.O
But i cannot make an instance of it, because it's abstract. -
QIcon myIcon =QApplication::style()->standardIcon(QStyle::SP_TitleBarMinButton);
-
that works now :D
Do you know an easy way to make the icon white instead of black?? -
const auto avalSize = myIcon.availableSizes(); QIcon invertedIcon; for(auto& singleSize : avalSize){ QImage tempImage = myIcon.pixmap(singleSize).toImage(); tempImage.invertPixels(); invertedIcon.addPixmap(QPixmap::fromImage(std::move(tempImage))); }
-
The maximize icon worked fine, but the minimize is not very good. Any ideas what may happened here??
-
@VRonin i need your help once more.
There are a few new findings. I need this splashscreen for a plugin that is compiled to .dll Because it's really much overhead to compile, deactivate the plugin, copy the dll, activate the plugin, test it, change code,... i copied a few parts to a test project. It's the same code, but different results.
Sourcecode for the whole plugin: https://git.rwth-aachen.de/carstenf/qtTsOverlay/tree/master
Test project: https://git.rwth-aachen.de/carstenf/testProject/tree/masterPlugin:
the minimize icon looks like on the picture above
the maximize icon works fine
when i select a item it is slightly highlighted white and the icon becomes a blue hue
when something is selected and i press the button or switch to an other window the text does not change, the highlight disappears, the icon is white againTest application:
the minimize and maximize icon work both
when i select a item it gets a black dotted border and the icon becomes a blue hue
when something is selected and i press the button or switch to an other window the text become black, the dotted border disappears, the icon is still blueWhy is there this different behaviour and how can i fix it to this:
the minimize and maximize icon work both :P
when i select a item there is no highlight, no text an icon changes.
when something is selected and i press the button or switch to an other window nothing changes -
QIcon invertedIcon; for(auto singleMode : {QIcon::Normal,QIcon::Disabled,QIcon::Active,QIcon::Selected}){ for(auto singleState : {QIcon::On,QIcon::Off}){ const auto avalSize = myIcon.availableSizes(singleMode ,singleState ); for(auto& singleSize : avalSize){ QImage tempImage = myIcon.pixmap(singleSize,singleMode ,singleState).toImage(); tempImage.invertPixels(); invertedIcon.addPixmap(QPixmap::fromImage(std::move(tempImage)),singleMode,singleState); } } }
-
@VRonin still the same problem (updated the source on the repo.)
But the wrong icon the one thing, the other is that blue hue at the icons from the list entries
-
yes, this just inverts the colours of every icon. it will will just take a negative (like good old film cameras do), if you want to do something more refined, then that just replace
tempImage.invertPixels();
with whatever pixel manipulation you want to apply. I also forgot the state and modeinmyIcon.pixmap
above, fixed now -
@VRonin invert is just fine. It works in the testsoftware. But in the final plugin (same code you can check it in the repositories i posted) it does not work