http://www.codeprogress.com/cpp/libraries/qt/showQtExample.php?index=193&key=QSpinBoxTextColor
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #include "spinboxwidget.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); spinboxWidget w; w.show(); return a.exec(); } | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | #ifndef SPINBOXWIDGET_H #define SPINBOXWIDGET_H #include <QWidget> #include <QSpinBox> class spinboxWidget : public QWidget { Q_OBJECT public: spinboxWidget(QWidget *parent = 0); ~spinboxWidget(); private: QSpinBox *spinbox; }; #endif // SPINBOXWIDGET_H | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | /* * This code shows how to change QSpinBox text color */ #include "spinboxwidget.h" spinboxWidget::spinboxWidget(QWidget *parent) : QWidget(parent) { spinbox = new QSpinBox(this); spinbox->setWindowTitle("QSpinBox Text Color"); spinbox->setFixedSize(150, 50); QPalette *palette = new QPalette(); palette->setColor(QPalette::Text, Qt::red); spinbox->setPalette(*palette); } spinboxWidget::~spinboxWidget() { } | cs |
반응형