追寻梦想的路

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
Qt Creator中创建一个简单应用界面,显示一个spinbox、一个silder,一个TextEdit,textEidt中显示date。


#include "mainwindow.h" #include <QApplication> #include <QHBoxLayout> #include <QPushButton> #include<QSlider> #include <QSpinBox> #include <QDateTime> #include <QTextEdit> #include <QTime> int main(int argc, char *argv[]) { QApplication app(argc, argv); QWidget *window = new QWidget(); window->setWindowTitle("Enter your age:"); QSlider *slider = new QSlider(Qt::Horizontal); slider->setRange(0,100); QSpinBox *spinBox = new QSpinBox(); spinBox->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(5); QDate *date = new QDate(2015,8,10); QTextEdit *text = new QTextEdit(); text->setText(date->toString()); QHBoxLayout *layout = new QHBoxLayout(); layout->addWidget(spinBox); layout->addWidget(slider); layout->addWidget(text); window->setLayout(layout); window->show(); return app.exec(); }

posted on 2015-06-23 14:26  追寻梦想的路  阅读(234)  评论(0编辑  收藏  举报