流云飞飞

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::

随笔分类 -  Qt

摘要:在使用QT + VS2005编译程序时,有时出现如下错误:错误 1 error LNK2001: 无法解析的外部符号 "public: virtual struct QMetaObject const * __thiscall Widget::metaObject(void)const " (?metaObject@Widget@@UBEPBUQMetaObject@@XZ) 错误 2 error LNK2001: 无法解析的外部符号 "public: virtual void * __thiscall Widget::qt_metacast(char const 阅读全文
posted @ 2013-05-01 11:12 流云飞飞 阅读(5235) 评论(0) 推荐(0)

摘要:使用QFileDialog可以调用当前系统的文件对话框包含头文件:#include <QFileDialog>(1)文件打开对话框QString getOpenFileName ( QWidget * parent = 0, const QString & caption = QString(), const QString & dir = QString(), const QString & filter = QString(), QString * selectedFilter = 0, Options options = 0 )第一个参数parent, 阅读全文
posted @ 2013-02-26 13:47 流云飞飞 阅读(41468) 评论(1) 推荐(1)

摘要:转自:http://blog.csdn.net/ymc0329/article/details/7975654//拷贝文件:bool MyTest007::copyFileToPath(QString sourceDir ,QString toDir, bool coverFileIfExist){ toDir.replace("\\","/"); if (sourceDir == toDir){ return true; } if (!QFile::exists(sourceDir)){ return false; } QDir... 阅读全文
posted @ 2013-02-21 09:13 流云飞飞 阅读(4111) 评论(0) 推荐(0)

摘要:QtCreator:没有CDB二进制档可用为二进制格式在'x86-windows-msvc2008-pe-32bit'"最近安装QtCreator, 可以编译运行程序, 启动调试时提示: "没有CDB二进制档可用为二进制格式在'x86-windows-msvc2008-pe-32bit" 这样的错误;解决方法: 网上搜索并安装dbg_x86_6.11.1.404.msi ,然后重启QtCreator, 打开 【工具】-【构建和运行】-【工具链】编辑器自动识别了调试器即可。 阅读全文
posted @ 2013-01-07 14:04 流云飞飞 阅读(769) 评论(0) 推荐(0)

摘要:在线程间发送自定义消息时,出现如下问题:QObject::connect: Cannot queue arguments of type 'ThreadSignal' (Make sure 'ThreadSignal' is registered using qRegisterMetaType().)解决方法如下,在代码中添加:qRegisterMetaType<ThreadSignal>("ThreadSignal"); 阅读全文
posted @ 2012-12-18 17:10 流云飞飞 阅读(7548) 评论(0) 推荐(0)

摘要:在ui界面添加Qlabel控件,在QLabel中使用QMovie播放gif。#include "WaitDialog.h"#include#includeWaitDialog::WaitDialog(QWidget *parent, QString fileName, int picWidth, int picHeight) : QWidget(parent){ ui.setupUi(this); m_picWidth = picWidth; m_picHeight = picHeight; this->setFixedSize(m_picWidth,m_picH.. 阅读全文
posted @ 2012-12-18 14:50 流云飞飞 阅读(10435) 评论(0) 推荐(1)

摘要:QDesktopWidget *deskdop = QApplication::desktop();move((deskdop->width() - this->width())/2, (deskdop->height() - this->height())/2); 阅读全文
posted @ 2012-12-18 14:20 流云飞飞 阅读(9654) 评论(0) 推荐(1)

摘要:进度条:代码如下:#include <QtGui/QApplication>#include <QProgressBar> #include <QThreadPool>#include <QTest>#include <QtCore>class RunnableTask : public QRunnable{public: RunnableTask(QProgressBar* progressBar) { m_ProgressBar = progressBar; } void run() { for (int i = 1; i < 阅读全文
posted @ 2012-12-13 16:43 流云飞飞 阅读(8964) 评论(0) 推荐(0)

摘要:程序中经常需要统计时间,需要统计某项运算的运行时间时,需要计算时间差。1.Qt内部封装了一个时间统计的方法:QTime类(注意不是QTimer,QTimer是计时用的)QTime类使用手册将官方文档:http://qt-project.org/doc/qt-4.8/qtime.html代码示例如下:#include <QTime>QTime time;time.start(); //开始计时,以ms为单位int time_Diff = time.elapsed(); //返回从上次start()或restart()开始以来的时间差,单位ms//以下方法是将ms转为sfloat f 阅读全文
posted @ 2012-12-13 14:23 流云飞飞 阅读(2910) 评论(0) 推荐(0)

摘要:#include <QtGui/QApplication>#include <QTextCodec>#include "mainwindow.h"int main(int argc, char *argv[]){ QApplication a(argc, argv); //添加代码 QTextCodec::setCodecForTr(QTextCodec::codecForName("GB2312")); QTextCodec::setCodecForLocale(QTextCodec::codecForName("GB 阅读全文
posted @ 2012-12-13 13:26 流云飞飞 阅读(431) 评论(0) 推荐(0)

摘要:QTreeWidgetItem *root = new QTreeWidgetItem(ui.treeWidget, QStringList(fileName)); root->setIcon(0, QIcon("./Resources/RsProduct16.gif")); QIcon icon; icon.addPixmap(QPixmap("./Resources/RsGroupOpen16.gif"), QIcon::Normal, QIcon::On);//节点打开状态 icon.addPixmap(QPixmap("./Res 阅读全文
posted @ 2012-12-10 10:14 流云飞飞 阅读(6775) 评论(0) 推荐(0)

摘要:在Qt+VS2005下,使用slot函数customContextMenuRequested(QPointpos)实现Treewidget的右键菜单栏。1、在ui编辑界面中,右击QTreeWidget--> Connect Signal-->选择customContextMenuRequested(QPoint),添加slot函数。 在属性设置中,将contextMenuPolicy属性要设置为:CustomContextMenu,这步不能忘记,否则右键无反应。2、为Treewidget添加节点,通过setData()来为每个节点赋予不同的键值。QTreeWidgetItem *r 阅读全文
posted @ 2012-12-07 17:17 流云飞飞 阅读(16628) 评论(0) 推荐(1)

摘要:我项目的环境是VS2005,Qt4.7.1步骤1.在项目中添加rc文件,例如命名为“icon.rc”;2.修改icon.rc文件,打开项目文件夹,用txt打开icon.rc,在最后面添加"IDI_ICON1 ICON DISCARDABLE "myapp.ico"",myapp.ico是要载入的图标文件;3.将myapp.ico拷贝到工程目录文件夹下;4.在VS2005界面中,在工程的Resource Files目录下添加icon.rc;4.重新生成程序。 阅读全文
posted @ 2012-12-05 17:18 流云飞飞 阅读(1763) 评论(0) 推荐(0)

摘要:QString file_full, file_name, file_path,file_suffix ;QFileInfo fileinfo;file_full = QFileDialog::getOpenFileName(this,.....);fileinfo = QFileInfo(file_full);//文件名file_name = fileinfo.fileName(); //文件后缀file_suffix = fileinfo.suffix()//绝对路径file_path = fileinfo.absolutePath(); 阅读全文
posted @ 2012-12-05 16:17 流云飞飞 阅读(19541) 评论(0) 推荐(1)

摘要:编译VS2005+QT工程师出现这个错误,网上查找的解决方法皆不管用。自己摸索时发现:出问题的.h文件右击【属性】-【配置属性】-【自定义生成步骤】-【常规】-【命令行】中命令如下:(为了容易查看我加了换行)命令1"$(QTDIR)\bin\moc.exe" -D -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_CORE_LIB -DQT_GUI_LIB -I".\." -I".\GeneratedFiles\." -I".\GeneratedFiles\$(Co 阅读全文
posted @ 2012-12-05 10:51 流云飞飞 阅读(4394) 评论(0) 推荐(0)

摘要:转自http://bbs.csdn.net/topics/320153514QT的中文站址QT教程BIG5http://www.csdn.net/linux/document/programme/qt.zip;一个台湾人写的QT说明文档,翻译自QT带的英文文档,不是很全面。http://www-900.ibm.com/developerWorks/cn/cnpapers.nsf/linux-papers-bynewest?openview&count=1000;IBM的developworks网页,其中有一些linux三剑客之一于明俭写的一些关于qt的文章。http://www.qil 阅读全文
posted @ 2012-11-29 17:09 流云飞飞 阅读(387) 评论(0) 推荐(0)

摘要:最近学习Qt加载XML以下代码是Qt的示例代码 1 void ClassA::loadXML() { 2 3 m_pDocument = new QDomDocument("loadXML"); 4 m_pFile= new QFile("./a.xml"); 5 bool flag = m_pFile->open(QIODevice::ReadOnly); 6 if (!flag) 7 return; 8 9 if (!m_pDocument->setContent(m_pFile)) {10 m_pFile->cl... 阅读全文
posted @ 2012-11-27 11:16 流云飞飞 阅读(1877) 评论(0) 推荐(0)

摘要:1.添加头文件#include <QtUiTools/QUiLoader>2.添加库文件在项目-> 属性-> 链接器-> 输入-> 附加依赖项中添加QtUiTools.lib3.添加调用代码 1 void LoadUi::load() 2 { 3 QUiLoader loader; 4 QFile file("./Form/myForm.ui"); 5 bool flag = file.open(QFile::ReadOnly); 6 QWidget *myWidget = loader.load(&file); 7 file.c 阅读全文
posted @ 2012-11-23 10:21 流云飞飞 阅读(364) 评论(0) 推荐(0)

摘要:Qt 4推出了一组新的item view类,它们使用model/view结构来管理数据与表示层的关系。这种结构带来的功能上的分离给了开发人员更大的弹性来定制数据项的表示,它也提供一个标准的model接口,使得更多的数据源可以被这些item view使用。 阅读全文
posted @ 2012-11-22 10:14 流云飞飞 阅读(37992) 评论(1) 推荐(2)