Convert ColorWidget from QWidget to QFrame and make use of The Box Model(tm) in stylesheet
authorunc0rr
Sat, 13 Oct 2012 00:35:20 +0400
changeset 7749 edad8a7bcaea
parent 7748 f160fbc139b1
child 7750 31e4f6c1834b
Convert ColorWidget from QWidget to QFrame and make use of The Box Model(tm) in stylesheet
QTfrontend/ui/widget/colorwidget.cpp
QTfrontend/ui/widget/colorwidget.h
--- a/QTfrontend/ui/widget/colorwidget.cpp	Sat Oct 13 00:07:46 2012 +0400
+++ b/QTfrontend/ui/widget/colorwidget.cpp	Sat Oct 13 00:35:20 2012 +0400
@@ -1,17 +1,17 @@
 #include <QStandardItemModel>
 #include <QMouseEvent>
 #include <QWheelEvent>
+#include <QColor>
 
 #include "colorwidget.h"
 #include "hwconsts.h"
 
 ColorWidget::ColorWidget(QStandardItemModel *colorsModel, QWidget *parent) :
-    QWidget(parent)
+    QFrame(parent)
 {
     m_colorsModel = colorsModel;
 
     setColor(0);
-    setStyleSheet("");
     setAutoFillBackground(true);
 
     connect(m_colorsModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(dataChanged(QModelIndex,QModelIndex)));
@@ -30,9 +30,12 @@
 
     QStandardItem * item = m_colorsModel->item(m_color);
 
+    setStyleSheet(QString("border: 2px solid orange; border-radius: 8px; background: %1").arg(item->data().value<QColor>().name()));
+    /*
     QPalette p = palette();
     p.setColor(QPalette::Window, item->data().value<QColor>());
     setPalette(p);
+    */
 
     emit colorChanged(m_color);
 }
--- a/QTfrontend/ui/widget/colorwidget.h	Sat Oct 13 00:07:46 2012 +0400
+++ b/QTfrontend/ui/widget/colorwidget.h	Sat Oct 13 00:35:20 2012 +0400
@@ -1,7 +1,7 @@
 #ifndef COLORWIDGET_H
 #define COLORWIDGET_H
 
-#include <QWidget>
+#include <QFrame>
 #include <QModelIndex>
 
 namespace Ui {
@@ -10,7 +10,7 @@
 
 class QStandardItemModel;
 
-class ColorWidget : public QWidget
+class ColorWidget : public QFrame
 {
     Q_OBJECT