widgets/colorbutton.h

Sat, 08 Apr 2023 15:08:19 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Sat, 08 Apr 2023 15:08:19 +0300
changeset 346
3e3784c4cd3e
parent 344
a24da8de2a3b
child 347
5c655cc006de
permissions
-rw-r--r--

Change color edit coloring to use only stylesheets to colorise the line edit only

#pragma once
#include <QPushButton>
#include <QLineEdit>

/**
 * @brief A button that can be used to select a color
 */
class ColorButton : public QWidget
{
	Q_OBJECT
	Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
	QLineEdit* lineEdit;
	QPushButton* button;
public:
	ColorButton(const QColor& color = {}, QWidget* parent = nullptr);
	ColorButton(QWidget* parent = nullptr);
	QColor color() const;
	Q_SLOT void setColor(const QColor& color);
	Q_SIGNAL void colorChanged(const QColor& color);
};

mercurial