#ifndef WIDGET_H
#define WIDGET_H
#include <QWidget>
#include <QPushButton>
class Widget : public QWidget
{
Q_OBJECT
public:
Widget(QWidget *parent = 0);
~Widget();
public slots:
// void onButt();
public:
// QPushButton *butt;
};
#endif // WIDGET_H
#include "widget.h"
//#include <QFileDialog>
class QString;
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
// butt = new QPushButton(tr("open"), this);
// connect(butt, SIGNAL(clicked()), this, SLOT(onButt()));
}
Widget::~Widget()
{
}
//void Widget::onButt()
//{
// QString dir = QFileDialog::getExistingDirectory(this,
// tr("Choose the directory!"), tr("../..\../"),
// QFileDialog::ShowDirsOnly);
//}
//
#include <QtGui>
#include "widget.h"
#include <QApplication>
#include <QPushButton>
#include <QVBoxLayout>
#include <QLabel>
#include <QCheckBox>
#include <QComboBox>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget *w = new Widget;
//************************ Widget背景色彩效果 ************************
a.setStyleSheet("Widget{background-color: \
qlineargradient(x1:0, y1:0, x2:1, y2: 1, \
stop:0 white, stop:0.4 gray, \
stop:1 green);}");
//************************ Widget背景色彩效果 ************************
// w->setStyleSheet("QPushButton{background-color: gray;}");
// w->setStyleSheet("QPushButton[text=Butt1]{color: red;}");
QPushButton *butt1 = new QPushButton("Butt1");
QPushButton *butt2 = new QPushButton("Butt2");
QPushButton *butt3 = new QPushButton("Butt3");
QLabel *label = new QLabel(QObject::trUtf8("选择以下按钮"));
QCheckBox *checkbox = new QCheckBox(QObject::trUtf8("复选框"));
QComboBox *combobox = new QComboBox;
QLineEdit *lineEdit = new QLineEdit;
label->setStyleSheet("color: rgb(0, 0, 127); \
font: 10pt;");
butt1->setStyleSheet("color: red; \
background-color: gray; \
image: url(:img/images/qt-front.png);");
w->setStyleSheet("QPushButton[text=""Butt2""]{ \
color: black; \
background-color: yellow;} \
QPushButton[text=""Butt3""]{ \
color: yellow; \
background-color: red;} \
QPushButton:hover{ \
background-color: darkblue;} \
QCheckBox::indicator{ \
width: 30px; \
height: 30px;} \
QCheckBox{ \
spacing: 8px;} \
QCheckBox:hover:!checked{ \
color: yellow;} \
QCheckBox:checked, QCheckBox:hover{ \
color: red;} \
QComboBox::drop-down:hover{ \
image: url(:img/images/qt-front.png);} \
QLineEdit{ \
padding: 0px 15px 0px 0px; \
color: rgb(127, 0, 63); \
background-color: rgb(255, 255, 241); \
selection-color: rgb(255, 255, 241); \
selection-background-color: rgb(127, 0, 63); \
border: 3px groove blue; \
border-radius: 10px;}");
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(label);
layout->addWidget(butt1);
layout->addWidget(butt2);
layout->addWidget(butt3);
layout->addStretch();
layout->addWidget(checkbox);
layout->addWidget(combobox);
layout->addWidget(lineEdit);
w->setLayout(layout);
w->show();
return a.exec();
}
#define WIDGET_H
#include <QWidget>
#include <QPushButton>
class Widget : public QWidget
{
Q_OBJECT
public:
Widget(QWidget *parent = 0);
~Widget();
public slots:
// void onButt();
public:
// QPushButton *butt;
};
#endif // WIDGET_H
#include "widget.h"
//#include <QFileDialog>
class QString;
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
// butt = new QPushButton(tr("open"), this);
// connect(butt, SIGNAL(clicked()), this, SLOT(onButt()));
}
Widget::~Widget()
{
}
//void Widget::onButt()
//{
// QString dir = QFileDialog::getExistingDirectory(this,
// tr("Choose the directory!"), tr("../..\../"),
// QFileDialog::ShowDirsOnly);
//}
//
#include <QtGui>
#include "widget.h"
#include <QApplication>
#include <QPushButton>
#include <QVBoxLayout>
#include <QLabel>
#include <QCheckBox>
#include <QComboBox>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget *w = new Widget;
//************************ Widget背景色彩效果 ************************
a.setStyleSheet("Widget{background-color: \
qlineargradient(x1:0, y1:0, x2:1, y2: 1, \
stop:0 white, stop:0.4 gray, \
stop:1 green);}");
//************************ Widget背景色彩效果 ************************
// w->setStyleSheet("QPushButton{background-color: gray;}");
// w->setStyleSheet("QPushButton[text=Butt1]{color: red;}");
QPushButton *butt1 = new QPushButton("Butt1");
QPushButton *butt2 = new QPushButton("Butt2");
QPushButton *butt3 = new QPushButton("Butt3");
QLabel *label = new QLabel(QObject::trUtf8("选择以下按钮"));
QCheckBox *checkbox = new QCheckBox(QObject::trUtf8("复选框"));
QComboBox *combobox = new QComboBox;
QLineEdit *lineEdit = new QLineEdit;
label->setStyleSheet("color: rgb(0, 0, 127); \
font: 10pt;");
butt1->setStyleSheet("color: red; \
background-color: gray; \
image: url(:img/images/qt-front.png);");
w->setStyleSheet("QPushButton[text=""Butt2""]{ \
color: black; \
background-color: yellow;} \
QPushButton[text=""Butt3""]{ \
color: yellow; \
background-color: red;} \
QPushButton:hover{ \
background-color: darkblue;} \
QCheckBox::indicator{ \
width: 30px; \
height: 30px;} \
QCheckBox{ \
spacing: 8px;} \
QCheckBox:hover:!checked{ \
color: yellow;} \
QCheckBox:checked, QCheckBox:hover{ \
color: red;} \
QComboBox::drop-down:hover{ \
image: url(:img/images/qt-front.png);} \
QLineEdit{ \
padding: 0px 15px 0px 0px; \
color: rgb(127, 0, 63); \
background-color: rgb(255, 255, 241); \
selection-color: rgb(255, 255, 241); \
selection-background-color: rgb(127, 0, 63); \
border: 3px groove blue; \
border-radius: 10px;}");
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(label);
layout->addWidget(butt1);
layout->addWidget(butt2);
layout->addWidget(butt3);
layout->addStretch();
layout->addWidget(checkbox);
layout->addWidget(combobox);
layout->addWidget(lineEdit);
w->setLayout(layout);
w->show();
return a.exec();
}