Cpper
C/C++高级工程师 Android高级软件工程师 IT集成工程师 音频工程师 熟悉c,c++,java,c#,py,js,asp等多种语言 程序猿
Styles是QT自带的例子 - 主要展示的是QT程序界面风格方面的编程知识
1.程序调色板的获取
使用QApplication中的静态函数
QApplication::palette
palette有2个版本一个是给定的调色板,另外一个给定的调色板
对应的调用QApplication::setPalette就可以设置新的程序调色板
如果使用自定义的Palette就可以达到修改界面色调的目的
比如:
2.
QStyleFactory对象
The QStyleFactory class creates QStyle objects.
可以通过静态函数QStyleFactory::key()获取工厂所支持的风格名字列表(注意是列表,返回类型是QStringList)
当然可以通过函数cerate来生成新的风格指针
3.
QComboBox 组合框
主要函数有以下几个:
通过函数
addItem增加新项
通过addItems增加新项列表
通过插槽绑定就可以传递响应了:
connect(combobox,SIGNAL(activated(QString)),this, SLOT(changeComBox(QString)));
其他三个可能会用到的函数

currentIndex,count, currentText

4.QT计时器
拿例子说下:
QTimer *timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), 
this, SLOT(advanceProgressBar()));
    timer
->start(1000);
首先构造一个计时器 然后绑定计时器对象和槽函数
之后启用计时器-每隔1秒钟调用advaceProressBar函数
如果想停止计时器则调用stop函数即可
5.QProgressBar进度条对象
基本的函数就那些
设置方向,当前值,最大值最小值,文本,可见性等等
progressBar = new QProgressBar;
progressBar
->setRange(010000);
progressBar
->setValue(0);
其槽函数为

valueChanged ( int value )

6.单选按钮QRodioButton
例子如下
    topLeftGroupBox = new QGroupBox(tr("Group 1"));
    radioButton1 
= new QRadioButton(tr("Radio button 1"));
    radioButton2 
= new QRadioButton(topLeftGroupBox);
    radioButton2
->setText(tr("Radio button 2"));
    radioButton3 
= new QRadioButton(tr("Radio button 3"));
    radioButton1
->setChecked(true);
    layout
->addWidget(radioButton1);
    layout
->addWidget(radioButton2);
    layout
->addWidget(radioButton3);
似乎没什么可说的
7.
QTableWidget控件
The QTableWidget class provides an item-based table view with a default model.
需要说明的是如果要使用自定义类型,则需要使用QTableView而非QTableWidget.
tableWidget = new QTableWidget(this);
     tableWidget
->setRowCount(10);
     tableWidget
->setColumnCount(5);
不过感觉以后不会使用这个对象
8.QLineText
QT的单行输入控件
具体函数有(似乎不需要说功能了)
QString text() const;
QString displayText() 
const;
int maxLength() const;
void setMaxLength(int);
bool isReadOnly() const;
void setReadOnly(bool);
bool isModified() const;
void setModified(bool);
9.
Q_INIT_RESOURCE(styles);
加载资源文件
styles.qrc

posted on 2011-03-20 12:19 ccsdu2009 阅读(1160) 评论(0)  编辑 收藏 引用 所属分类: QT编程