Qt学习五:控件二:下拉列表框、字体下拉列表框、QSpinBox控件、QScrollBar控件
来源:互联网 发布:软件设计规范怎么写 编辑:程序博客网 时间:2024/06/03 09:24
这是第二波控件
其中qtButton.h中的程序是
#ifndef QTBUTTON_H#define QTBUTTON_H#include <QtWidgets/QMainWindow>#include "ui_qtbutton.h"//-------------------------------#include<qcombobox.h>#include<qfontcombobox.h>#include<qpushbutton.h>#include<qlabel.h>#include<qspinbox.h>#include<qscrollbar.h>#include<qspinbox.h>//---------------------------class qtButton : public QMainWindow{Q_OBJECTpublic:qtButton(QWidget *parent = 0);~qtButton();private:Ui::qtButtonClass ui;QComboBox *comboBox;QFontComboBox *fontComboBox;QPushButton *button;QLabel *label;QSpinBox *spinBox;QScrollBar *scrollBar; //滚动条QSpinBox *spinBox1;private slots:void txtButton();};#endif // QTBUTTON_H
另外,qtButton.cpp里面的程序如下:
#include "qtbutton.h"qtButton::qtButton(QWidget *parent): QMainWindow(parent){ui.setupUi(this);//------------------ComboBox------comboBox = new QComboBox(this);comboBox->setGeometry(QRect(50, 50, 120, 25));QStringList str;str << "Methamatic" << "Chinese" << "Geometry";comboBox->addItems(str);//----------------------------------//----------------QFontComboBox------------fontComboBox = new QFontComboBox(this);button = new QPushButton(this);label = new QLabel(this);label->setGeometry(QRect(50, 150, 300, 25));button->setText("button");button->move(180, 100);//注意button控件的运行方式connect(button, SIGNAL(released()), this, SLOT(txtButton()));fontComboBox->setGeometry(QRect(50, 100, 120, 25));//----------------------------------------//-------------QSpinBox-------------------spinBox = new QSpinBox(this);spinBox->setGeometry(QRect(50, 150, 100, 25));spinBox->setRange(0, 200);spinBox->setValue(10);spinBox->setSuffix("Yan");spinBox->setPrefix("$");//----------------------------------------------------//---------ScrollBar---------------------scrollBar = new QScrollBar(this);scrollBar->setOrientation(Qt::Horizontal);scrollBar->setGeometry(QRect(50, 200, 180, 20));scrollBar->setPageStep(10);scrollBar->setValue(50);spinBox1 = new QSpinBox(this);spinBox1->setGeometry(QRect(50, 250, 100, 25));//必须把connect放在最下面;connect(scrollBar, SIGNAL(valueChanged(int)), spinBox1, SLOT(setValue(int)));connect(spinBox1, SIGNAL(valueChanged(int)), scrollBar, SLOT(setValue(int)));//---------------------------------------------}qtButton::~qtButton(){}void qtButton::txtButton(){label->setText("choose font:" + fontComboBox->currentText());}
最后运行结果如下:
0 0
- Qt学习五:控件二:下拉列表框、字体下拉列表框、QSpinBox控件、QScrollBar控件
- 下拉列表控件学习
- 下拉列表:comboBox控件
- PropertyGrid控件下拉列表
- Day18-下拉列表控件
- UGUI下拉列表控件
- ListView下拉列表控件
- Spinner下拉列表控件
- Spinner控件:下拉列表
- 无限级下拉列表框控件
- MFC下拉列表框(Combox)控件使用方法
- qt字体 QFontComboBox 字体下拉列表框
- 一款层次下拉列表控件
- 下拉列表时分秒控件
- Android 下拉列表Spinner控件
- android 控件 下拉列表(Spinner)
- Spinner控件显示下拉列表
- android----Spinner下拉列表控件
- UVA 11292[Dragon of Loowater ]
- 欢迎使用CSDN-markdown编辑器
- 设计模型之创建型模式之工厂方法模式(Factory Method)
- Calendar类简单常用的几种方法(java核心卷1-D3)
- 设计模型之创建型模式之抽象工厂模式(Abstract Factory)
- Qt学习五:控件二:下拉列表框、字体下拉列表框、QSpinBox控件、QScrollBar控件
- 4个Android Studio小技巧
- Node.js 工具模块
- Openstack组件部署 — Nova_安装和配置Controller Node
- 设计模型之创建型模式之单例模式(Singleton)
- Linux学习之软件安装(二)-常用软件安装列表
- 剑指offer——删除链表中重复的结点
- [adb]常用命令
- 中文转拼音,分组与排序