Chinaunix首页 | 论坛 | 博客
  • 博客访问: 847854
  • 博文数量: 156
  • 博客积分: 6553
  • 博客等级: 准将
  • 技术积分: 3965
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-22 18:36
文章存档

2012年(3)

2011年(43)

2010年(110)

分类: LINUX

2010-10-04 12:47:33

上面是效果图,拖动滚动条时,label上的数字会发生变化
 
 
代码实现如下:
Dialog.h文件代码
#ifndef DIALOG_H
#define DIALOG_H
#include
#include
#include
class Dialog:public QDialog
{
private:
    QLabel *label;
    QScrollBar *scrollbar;
public:
    Dialog(QWidget *parent = 0);
};
#endif // DIALOG_H

 
Dialog.cpp文件代码
#include "Dialog.h"
#include
Dialog::Dialog(QWidget *parent):QDialog(parent)
{
    label = new QLabel("0", this);
    label->setGeometry( 10, 10, 200, 300);
    scrollbar = new QScrollBar(this);
    scrollbar->setGeometry(200, 0, 20, 300);
    scrollbar->setRange(0, 300);
    QObject::connect(scrollbar, SIGNAL(valueChanged(int)),
                     label, SLOT(setNum(int)));
}
 
main.cpp代码:
#include
#include "Dialog.h"
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    Dialog d;
    d.show();
    return app.exec();
}
 
文件: signal.rar
大小: 153KB
下载: 下载
阅读(666) | 评论(0) | 转发(1) |
0

上一篇:自己写ping的实现

下一篇:标准IO实例一

给主人留下些什么吧!~~