Unsolved Customizing the QColorDialog for transparency in percentage
-
In QColorDialog, I can control the transparency by giving the option ShowAlphaChannel and change the alpha from 0 to 255. I'd like to control the transparency in terms of percentage. Is there an easy way to change the QColorDialog just so that the alpha channel / transparency control to be in %? Thanks.
-
@Pauly 128 is 50% of 255.
So, just calculate the alpha from percentage. -
Yes, I know that. I just want to replace the alpha value of 0~255 to the percentage, in terms of the GUI input method. Can I do it without dramatic effort like rebuilding the reset of QColorDialog?
-
@Pauly What does "GUI input method" mean?
What does "rebuilding the reset of QColorDialog" mean?
Can you explain better what you want to do? Do you want the user to control the transparency? -
In the QColorDialog, the transparency is set by entering a value (0~255) to alpha channel input. I would like to let user enter a percentage instead. I understand I can build my own widget to do anything I want, but since I'm ok with all other functions in QColorDialog except just the alpha channel entering, building a new widget for just that seems to be a lot of effort for minimum return.
I wonder if anyone knows a way to alter the alpha channel input so that it takes the percentage instead of value.
-
@Pauly As far as I can see there is nothing like this in QColorDialog. Most probably you will need to write that by yourself.
-
@Pauly
Hi
In theory , if using non native dialogs ( so its widgets), you might
be able to grab the the slider and input field and handle the % thing
Look into
QPushButton* button = dialog->findChild<QPushButton*>("Button name");
( replace button with edit type / slider type)That might allow it in a very hackish way.
For anything besides a for fun project, its not a good solution to hack the existing dialogs.
-
@mrjj said in Customizing the QColorDialog for transparency in percentage:
ght allow it in a very hackish
This sounds like a good idea. What is wrong with it?
BTW, how could I find the name of the button/edit box etc without the source code?
-
hmmm. So I try to do this to find out the spin box I want to hack in QColorDialog,
QColorDialog *newDialog=new QColorDialog(); QList<QSpinBox *> widgets = newDialog->findChildren<QSpinBox *>(); for (int i=0; i<widgets.size();i++) { qDebug()<<widgets[i]->objectName();}
and I get:
""
""
""
""
""
""
""no name??? How would it work or am I missing something?
-