#include <QApplication>
#include <QLabel>
#include <QPushButton>
#include <QSpinBox>
#include <QSlider>
#include <QHBoxLayout>
int main(int argc,char* argv[])
{
QApplication app(argc,argv);
//QLabel* label = new QLabel("<h2><i>xxx</i>""<font color=red>xxx</font></h2>");
//label->show();
//QPushButton* button = new QPushButton("quit");
//QObject::connect(button,SIGNAL(clicked()),&app,SLOT(quit()));
//button->show();
QWidget* widget = new QWidget; // 总框架
widget->setWindowTitle("love");
QSpinBox* spinbox = new QSpinBox;
QSlider* slider = new QSlider(Qt::Vertical);
spinbox->setRange(0,100);
slider->setRange(0,100);
QObject::connect(spinbox,SIGNAL(valueChanged(int)),slider,SLOT(setValue(int)));
QObject::connect(slider,SIGNAL(valueChanged(int)),spinbox,SLOT(setValue(int)));
spinbox->setValue(50);
QHBoxLayout* layout = new QHBoxLayout;
layout->addWidget(spinbox);
layout->addWidget(slider);
widget->setLayout(layout);
widget->show();
return app.exec();
}
ps: qt 布局管理器 (QGridLayout , QVBoxLayout , QHBoxLayout)_(矩阵 垂直 竖直)
程序员的任务就是实例化所需要的控件,按照需要设置它们的属性,把它们放到布局管理器中
界面中要完成任务由Qt 的signal 和slot 完成