I have a QDialog
subclass that presents some options to the user for their selecting. One of these options is a color. I have seen the QColorDialog
, and I need something much simpler, that is also a regular widget so I can add to my layout as part of my dialog. Does Qt offer anything like this or will I have to make my own? If the latter, what is the best strategy?
相关问题
- QML: Cannot read property 'xxx' of undefin
- QTextEdit.find() doesn't work in Python
- Qt 5.0.1: Application will not execute outside of
- QT Layouts, how to make widgets in horizontal layo
- QT Layouts, how to make widgets in horizontal layo
相关文章
- ubuntu20.4中c#通过c++库调用python脚本
- Qt槽函数自动执行多遍
- Is there a non-java, cross platform way to launch
- How to get a settings storage path in a cross-plat
- How to set the font size of the label on pushbutto
- Why doesn't valgrind detect a memory leak in m
- Checking & Unchecking Checkboxes inside a JQuery M
- QTreeView remove decoration/expand button for all
Have you looked at the QtColorPicker, part of Qt Solutions?
QtColorPicker provides a small widget in the form of a
QComboBox
with a customizable set of predefined colors for easy and fast access. Clicking the...
button will open theQColorDialog
. It's licensed under LGPL so with dynamic linking and proper attribution it can be used in commercial software. Search for QtColorPicker and you'll find it. Here's a link to one site that hosts many of the Qt Solutions components:https://github.com/pothosware/PothosFlow/tree/master/qtcolorpicker
Qt doesn't offer anything simpler than QColorDialog natively, but there are several color picking widgets as part of wwWidgets, a user made set of widgets for Qt (note that this is "wwWidgets" with a "w" and not "wxWidgets" with an "x").
I think QColorDialog is best suited for your application. If you want to go for something simpler, it will come with reduced functionality. I'm not aware of any standard widget in Qt offering such an option but you can try out the following:
QCombobox with each entry corresponding to a different color. You can maybe even have the colors of the names in their actual color.
One or more slider bars to adjust the hue, saturation, val or R,G,B components.
QLineEdit fields for individual R,G,B components. You can also have a signal / slot mechanism wherein once the user changes a color, the color shown to the user gets changed accordingly.
You can have '+' and '-' signs to increase / decrease the above color component values.
I hope the above gives you some ideas.
There's a very easy way to implement that using a
QPushButton
to display the current color and pickup one when it is clicked:Definition:
Implementation: