代码改变世界

随笔分类 -  C++

QT小例子 ---文件查找

2012-04-13 23:37 by Rollen Holt, 6857 阅读, 收藏, 编辑
摘要: 先看看效果图吧,可以查找文件,以及通过文件内容进行查找 #ifndef WINDOW_H #define WINDOW_H #include <QDialog> #include <QDir> QT_BEGIN_NAMESPACE class QComboBox; class QLabel; class QPushButton; class QTableWidget; c... 阅读全文

QT使用打印机

2012-04-13 20:52 by Rollen Holt, 6391 阅读, 收藏, 编辑
摘要: 主要代码如下: void PrintText::slotPrint () { QPrinter printer; QPrintDialog printDialog(&printer, this); if (printDialog.exec()) { QTextDocument *doc = contentTextEdit->document(); ... 阅读全文

c++小技巧,不解释

2012-04-13 19:20 by Rollen Holt, 554 阅读, 收藏, 编辑
摘要: 阅读全文

字符数组,字符指针,sizeof,strlen总结

2012-04-12 13:23 by Rollen Holt, 9581 阅读, 收藏, 编辑
摘要: 先看下面这一段代码,读者可以自己思考一下,是否自己可以完全答对 // test.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <iostream>#include<cstdio>#include <string>using namespace std;struc... 阅读全文

strlen源码,远没有想象中的那么简单、、、、

2012-04-12 12:19 by Rollen Holt, 1807 阅读, 收藏, 编辑
摘要: /****strlen - return the length of a null-terminated string**Purpose:* Finds the length in bytes of the given string, not including* the final null character.**Entry:* const char * str - string whose length is to be computed**Exit:* length of the string "str", exclusive of th... 阅读全文

QT实现启动画面

2012-04-10 21:02 by Rollen Holt, 1189 阅读, 收藏, 编辑
摘要: 只需要将主函数改为类似于下面的形式即可int main(int argc, char *argv[]){ QApplication a(argc, argv); QPixmap pixmap(":/splash.jpg"); QSplashScreen splash(pixmap); splash.show(); a.processEvents(); MainWindow w; w.show(); splash.finish(&w); return a.exec();} 阅读全文

QT实现可扩展对话框

2012-04-10 20:30 by Rollen Holt, 2478 阅读, 收藏, 编辑
摘要: extension.h #ifndef EXTESION_H#define EXTESION_H#include <QtGui>#include "ui_extesion.h"class Extesion : public QDialog{ Q_OBJECTpublic: Extesion(QWidget *parent = 0, Qt::WFlags flags = 0); ~Extes... 阅读全文

QT中的文件浏览

2012-04-10 19:34 by Rollen Holt, 4235 阅读, 收藏, 编辑
摘要: FileViewr.h #ifndef FILEVIEWR_H#define FILEVIEWR_H#include <QtGui>#include "ui_fileviewr.h"class FileViewr : public QDialog{ Q_OBJECTpublic: FileViewr(QWidget *parent = 0, Qt::WFlags flags = 0); ~... 阅读全文

QT获取文件信息

2012-04-10 17:20 by Rollen Holt, 3810 阅读, 收藏, 编辑
摘要: 效果图如下: 代码: FileInformation.h /******************************************************************** created: 2012/04/10 created: 10:4:2012 17:10 filename: F:\C++\FileInformation\FileInformat... 阅读全文

QT中progress的使用

2012-04-10 12:26 by Rollen Holt, 4207 阅读, 收藏, 编辑
摘要: progress。h #ifndef PROGRESS_H#define PROGRESS_H#include <QtGui>#include <QtTest>#include "ui_progress.h"class progress : public QDialog{ Q_OBJECTpublic: progress(QWidget *parent = 0, Qt::WFlags fl... 阅读全文

QT中QTableWidget的使用

2012-04-10 12:05 by Rollen Holt, 15526 阅读, 收藏, 编辑
摘要: table.h #ifndef TABLE_H#define TABLE_H#include <QtGui>#include "ui_table.h"class Table : public QTableWidget{ Q_OBJECTpublic: Table(); ~Table();private: Ui::TableClass ui;};#endif // TABLE_Htable.... 阅读全文

QT中QToolBox的使用,实现抽屉效果

2012-04-10 10:41 by Rollen Holt, 20652 阅读, 收藏, 编辑
摘要: drawer.h #ifndef DRAWER_H#define DRAWER_H#include <QtGui>#include "ui_drawer.h"class drawer : public QToolBox{ Q_OBJECTpublic: drawer( QWidget *parent=0, Qt::WindowFlags f=0 ); ~drawer(); QToolBu... 阅读全文

QT中各种MessageBox的使用

2012-04-10 09:54 by Rollen Holt, 36450 阅读, 收藏, 编辑
摘要: MessageBox.h #ifndef MESSAGEBOX_H#define MESSAGEBOX_H#include <QtGui>#include "ui_messagebox.h"class MessageBox : public QDialog{ Q_OBJECTpublic: MessageBox(QWidget *parent = 0, Qt::WFlags flags =... 阅读全文

QT中的QInputDialog的小例子

2012-04-10 09:27 by Rollen Holt, 7260 阅读, 收藏, 编辑
摘要: 其实这断代码没什么优秀之处,贴出来主要为为了方便自己和他人,因为以后如果用到这一块的话,这些代码可能能够直接拿过来用。 InpugDialog.h头文件: #ifndef INPUGDIALOG_H#define INPUGDIALOG_H#include <QtGui>#include "ui_inpugdialog.h"class InpugDialog : public QDialo... 阅读全文

向前插入迭代器

2012-04-09 23:18 by Rollen Holt, 485 阅读, 收藏, 编辑
摘要: * *向前插入迭代器,是架构在具有push_front向前插入函数的序列容器(比如deque list)上的输出迭代器,可以利用 *改迭代器提供的“++”,“*”,“=”以“*fii++=9;”的类似的形式完成容器元素的赋值。 * *其中“*”和"++"只是简单的返回对象本身:“*this”,所以必须和“=”操作一起使用才有意义。 **/#include "stdafx.h"#include <i... 阅读全文

常用数据结构算法 c++模板实现

2012-04-09 15:58 by Rollen Holt, 5216 阅读, 收藏, 编辑
摘要: 由于大三下学期了,快要找工作了,所以最近在复习一些学过的内容,以下是这几天写的数据结构里面的一些常用的算法,仅供参考。不过在平时做项目的时候,建议采用STL和Boost里面现成的东西,而不要自己去实现他们。另外,由于国内外讲解数据结构和算法的书籍很多,内容大多重复,所以笔者并没有自习讲解数据结构的原理,因为代码很简单,相信大家都可以看懂的。如果读者对于这一块比较生疏,本人推荐看看《算法导论》这本书,可能这本书不适合你作为入门的第一本书籍,但是这本书确实不错,可以作为你入门后经常翻阅的书、。顺序表单链表双向链表循环链表顺序栈链式栈顺序队列链式队列优先级队列串堆二叉树线索二叉树哈夫曼树树B+树图排 阅读全文

2012-04-09 15:44 by Rollen Holt, 933 阅读, 收藏, 编辑
摘要: MinHeap.h template<typename Type> class MinHeap{public: MinHeap(Type heap[],int n); //initialize heap by a array ~MinHeap(){ delete[] m_pheap; }public: bool Insert(const Type item); bool D... 阅读全文

哈夫曼树

2012-04-08 23:12 by Rollen Holt, 1180 阅读, 收藏, 编辑
摘要: BinTreeNode.htemplate<typename Type> class BinaryTree;template<typename Type> void Huffman(Type *, int, BinaryTree<Type> &);template<typename Type> class BinTreeNode{public: friend class BinaryTree<Type>; friend void Huffman<Type>(Type *, int, BinaryTree<Ty 阅读全文

数组的选择--固定大小数组模板array存在的意义!

2012-04-02 12:37 by Rollen Holt, 1469 阅读, 收藏, 编辑
摘要: 主要就是为了使用的方便,更加容易和algorithm的算法结合的更好! #include <iostream> #include <ctime> #include <array> #include <functional> #include <algorithm> #include <boost\array.hpp> using namespace std; using names... 阅读全文

使用模板元编程快速的得到斐波那契数。。

2012-04-02 12:32 by Rollen Holt, 913 阅读, 收藏, 编辑
摘要: 这是一种将运行时消耗转移到编译器消耗的方法,是c++模板的一种应用。 当你的程序运行时效率需要特别高的时候,可以考虑这样的方法。 模板实例化的时候需要常量: #include <iostream>using namespace std;template < unsigned N >struct Fib{ enum { Val = Fib<N-1>::Val + Fib<N-... 阅读全文