原创 設計模式之——狀態模式
state.h #ifndef STATE_H #define STATE_H #include <QtDebug> #include "context.h" class Context; class State { pub
原创 設計模式之——抽象工廠模式
user.h #ifndef IUSER_H #define IUSER_H class User { public: User() {} virtual void insert() = 0; }; class
原创 設計模式之——適配器模式
target.h #ifndef TARGET_H #define TARGET_H #include <QtDebug> class Target { public: Target(){} virtual v
原创 設計模式之——裝飾模式
shape.h #ifndef SHAPE_H #define SHAPE_H class Shape { public: Shape() {} virtual void draw() = 0; }; #e
原创 設計模式之——策略模式
strategy.h #ifndef STRATEGY_H #define STRATEGY_H class Strategy { public: Strategy(){} virtual int doOpera
原创 設計模式之——簡單工廠模式
product.cpp #include "product.h" #include <QtDebug> Product::Product() { } void Product::show() { qDebug() <<
原创 qt調用javaScript
pro文件 #------------------------------------------------- # # Project created by QtCreator 2019-07-08T14:24:54 # #--
原创 vs c++ 顯示加載dll
1、創建dll Dll4.h #ifdef DLL4_API #define DLL4_API _declspec(dllexport) #else #define DLL4_API _declspec(dllimport)
原创 循環中刪除list元素
1、程序崩潰,mylist越界。 #include "mainwindow.h" #include "ui_mainwindow.h" #include <QtDebug> #include <QListIterator> Ma
原创 關於錯誤信息:cannot call member function ' ' without object
1、 #include "mainwindow.h" #include <QApplication> #include <QtDebug> class Test { public: void test1(){qDebug(
原创 qt 實現托盤菜單
mainwindow.h #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QSystemTrayIcon> namespace
原创 QT 容器類
介紹 Qt庫提供了一套通用的基於模板的容器類,可以用這些類存儲指定類型的項。比如,你需要一個大小可變的QString的數組,則使用QVector。 這些容器類比STL(C++標準模板庫)容器設計得更輕量、更安全並且更易於使用。如果對S
原创 static關鍵字
1、定義局部變量 會被初始化爲0或者爲空。作用域跟局部變量一樣,但是static類型分配在靜態存儲區,在程序整個運行期間都不釋放。下次調用時,還是上次最後的值。 2、外部靜態變量/函數 用來表示不能被其它文件訪問的全局變量和函數。 3
原创 獲得qstring字符串的長度(字節長度和所佔的像素寬度)
1.QString 用length()返回字符串的長度,即字節數, 在中英文字符都是以 Unicode 方式編碼的,所以,無論中英文都算的長度爲 1。 想要取得英文長度爲 1 中文長度爲 2 的總長度,必須用toLocal8bit()