C++
JoYER_cc
相信梦想,相信技术。
展开
-
Qt学习合集
QT-QWidgt-QThread_JoYER_cc的博客-CSDN博客Qt-QString-字符集_JoYER_cc的博客-CSDN博客Qt-QLabel_JoYER_cc的博客-CSDN博客Qt-QLabel_JoYER_cc的博客-CSDN博客Qt-QPushButton_JoYER_cc的博客-CSDN博客Qt-QLineEdit_JoYER_cc的博客-CSDN博客Qt-QObjet结点_JoYER_cc的博客-CSDN博客QT-Layout_JoYER_cc的博客-C原创 2022-04-22 15:18:49 · 109 阅读 · 0 评论 -
Qt-Xps项目
ui_xps.h/********************************************************************************** Form generated from reading UI file 'xps.ui'**** Created by: Qt User Interface Compiler version 5.14.2**** WARNING! All changes made in this file will be lo原创 2022-04-22 15:11:03 · 401 阅读 · 0 评论 -
Qt-QPainter
画图,处理图像testqimage.cpp#include "testqimage.h"#include <QPainter>TestQImage::TestQImage(QWidget* parent) : QWidget(parent){ ui.setupUi(this); img = QImage(1280, 720, QImage::Format_RGBA8888); //填入颜色 img.fill(QColor(255, 0, 0, 200)); //遍历原创 2022-04-21 21:55:41 · 184 阅读 · 0 评论 -
Qt-QEvent
按键事件#include "qeventtest.h"#include <QDebug>#include<QEvent>#include <QKeyEvent>QEventTest::QEventTest(QWidget* parent) : QWidget(parent){ ui.setupUi(this); //this->setMouseTracking(true);}bool QEventTest::event(QEvent* ev原创 2022-04-21 17:41:43 · 325 阅读 · 0 评论 -
Qt-QMainWindow
main.cpp#include "qmenutest.h"#include <QtWidgets/QApplication>#include "menuwidget.h" int main(int argc, char *argv[]){ QApplication a(argc, argv); QMenuTest w; w.show(); /* MenuWidget win; win.show();*/ return a.exec原创 2022-04-21 13:23:45 · 344 阅读 · 0 评论 -
Qt-QDialog
main.cpp#include "qdialogtest.h"#include <QtWidgets/QApplication>#include <QDebug>#include "xmessagebox.h"#include "progressbar.h"#include "testprogressbar.h"int main(int argc, char *argv[]){ QApplication a(argc, argv); Pro原创 2022-04-20 15:23:35 · 420 阅读 · 0 评论 -
Qt-QTreeWidget
ui_qtreewidgettest.h/********************************************************************************** Form generated from reading UI file 'qtreewidgettest.ui'**** Created by: Qt User Interface Compiler version 5.14.2**** WARNING! All changes made原创 2022-04-18 17:26:05 · 502 阅读 · 0 评论 -
Qt-QTableWidget
ui_tablewidgettest.h/********************************************************************************** Form generated from reading UI file 'qtablewidgettest.ui'**** Created by: Qt User Interface Compiler version 5.14.2**** WARNING! All changes mad原创 2022-04-17 16:03:47 · 425 阅读 · 0 评论 -
Qt-QListWidget
qlistwidgettest.h#pragma once#include <QtWidgets/QWidget>#include "ui_qlistwidgettest.h"class QListWidgetTest : public QWidget{ Q_OBJECTpublic: QListWidgetTest(QWidget *parent = Q_NULLPTR);public slots: void Click(); void原创 2022-04-16 12:01:22 · 684 阅读 · 0 评论 -
Qt-QSlider
main.cpp#include "qslidertest.h"#include <QtWidgets/QApplication>int main(int argc, char *argv[]){ QApplication a(argc, argv); QSliderTest w; w.show(); return a.exec();}qslider.h#pragma once#include <QtWidgets/QWid.原创 2022-04-15 18:53:22 · 436 阅读 · 0 评论 -
Qt-QComboBox
qcomboxtext.h#pragma once#include <QtWidgets/QWidget>#include "ui_qcomboxtest.h"class QComBoxTest : public QWidget{ Q_OBJECTpublic: QComBoxTest(QWidget *parent = Q_NULLPTR);public slots: void Click(); void Act(int index);原创 2022-04-15 14:21:26 · 235 阅读 · 0 评论 -
Qt-QRadioButton
qradiobuttontest.h#pragma once#include <QtWidgets/QWidget>#include "ui_qradiobuttontest.h"class QRadioButtonTest : public QWidget{ Q_OBJECTpublic: QRadioButtonTest(QWidget *parent = Q_NULLPTR);public slots: void Save();priva.原创 2022-04-15 11:19:26 · 365 阅读 · 0 评论 -
Qt-QCheckBox
qcheckbox.h#pragma once#include <QtWidgets/QMainWindow>#include "ui_qcheckboxtest.h"class QCheckBoxTest : public QMainWindow{ Q_OBJECTpublic: QCheckBoxTest(QWidget *parent = Q_NULLPTR);public slots: void Click(bool check);原创 2022-04-15 10:10:05 · 821 阅读 · 0 评论 -
QT-Layout
QVBoxLayout不是一个Widget,目的是控件的大小和位置。sizeHint()推荐尺寸,重载进行修改尺寸,返回Qsiye。或者通过函数setMinimumSize和setMaximumSize进行设置最大最小值。QSizePolicy::PolicyFlagGrowFlagExpandFlagShrinkFlagIgnoreFlag拼接之后有:四种Layoutui_myqt1.h...原创 2022-04-14 16:32:26 · 673 阅读 · 0 评论 -
Qt-QObjet结点
//当项目复杂到一定程度时对各个组件结点进行处理#include "widget.h"#include "ui_widget.h"#include <QDebug>#include <iostream>using namespace std;static QObject *PrintName(QObject *obj){ if(!obj) { return NULL; } qDebug()<<obj-.原创 2022-04-14 11:47:15 · 334 阅读 · 0 评论 -
Qt-QLineEdit
ui_myqt.h/********************************************************************************** Form generated from reading UI file 'myqt.ui'**** Created by: Qt User Interface Compiler version 5.14.2**** WARNING! All changes made in this file will be原创 2022-04-14 10:22:07 · 444 阅读 · 0 评论 -
Qt-QPushButton
设置槽函数 void Pressed() { qDebug() << "pressed"; } void Released() { qDebug() << "released"; }设置快捷方式 ui.shotPushButton->setShortcut(tr("X")); //设置shotPushButton快捷键方式 ui.shotPushButton->原创 2022-04-13 15:06:12 · 560 阅读 · 0 评论 -
Qt-QLabel
main.cpp#include "myqt.h"#include <QtWidgets/QApplication>#include <QtWidgets>//#include <QDebug>//#include <iostream>//#include <windows.h>using namespace Qt;using namespace std;int main(int argc, char *argv[]){原创 2022-04-13 10:14:39 · 181 阅读 · 0 评论 -
Qt-QString-字符集
/*字符集ASCII 7位 128个字符 一般b7作奇偶校验ISO-8859-1 扩展ASCII 128-255拉丁字母ANSI 多字节字符集 0-127:1个字节代表1个字符 2个字节表示一个字符 GB2312 6763常用汉字 GBK 扩展GB2312 21003个汉字 UTF-8 变长编码方式 1字节 0xxxxxxx 2字节 110xxxxx 10xxxxxx 3字节 1110xxxx 10xxxxxx 10xxxxxx 4字节 11110x.原创 2022-04-11 16:30:31 · 881 阅读 · 0 评论 -
QT-QWidgt-QThread
main.cpp//#include "myqt.h"#include <QtWidgets/QApplication>#include <QtWidgets>#include "XWidget.h"#include "XThread.h"//QWidget* w = NULL; //QWidget声明XWidget* w = NULL;int main(int argc, char *argv[]){ QApplication a(argc, ar原创 2022-04-11 12:14:53 · 421 阅读 · 0 评论 -
C++-高级合集
C++-类_JoYER_cc的博客-CSDN博客C++-this指针-const重载_JoYER_cc的博客-CSDN博客C++-友元函数_JoYER_cc的博客-CSDN博客C++-静态成员_JoYER_cc的博客-CSDN博客C++-复制构造函数-赋值操作符_JoYER_cc的博客-CSDN博客C++-析构函数_JoYER_cc的博客-CSDN博客C++-潜复制-深复制-智能指针_JoYER_cc的博客-CSDN博客C++-操作符重载_JoYER_cc的博客-CSDN博客原创 2022-04-10 11:33:03 · 1032 阅读 · 0 评论 -
C++-特殊工具与技术
allocator类allocator<类名> 对象名;对象.allocate(分配的空间大小);RTTItypeid(*对象名/类名).name() //输出类名类成员的指针成员类型全称 类名::* 对象=&类名.成员名; //对象指向类的成员函数指针:函数返回值类型(类名::* 指针名)(参数类型) const = &类::成员函数;嵌套类:类里面还有类。union:共用存储空间 uni...原创 2022-04-10 11:23:07 · 919 阅读 · 0 评论 -
C++-多继承与虚基类
#include <iostream>using namespace std;enum COLOR {Red,Green,Blue,Yellow,White,Black,Brown};class Animal{public: Animal(int); virtual ~Animal() { cout << "Animal析构函数被调用...\n"; } virtual int GetAge() { return itsAge; } virtual void S.原创 2022-04-10 10:54:27 · 64 阅读 · 0 评论 -
C++-名称空间
全局名称空间没有名称,表示::类名/变量/函数名称空间可以嵌套 不同名称空间可以定义相同的类或函数或变量,表示为名称空间::类名/变量名/函数名在头文件里一般用名称空间的全名 导入名称空间using namespace 名称空间名;在源文件里建议不要全部导入所有的名称空间,而是使用哪个导入哪个using 名称空间名::名称;名称空间可以有别名namespace 别名=名称空间...原创 2022-04-09 20:57:08 · 508 阅读 · 0 评论 -
C++-异常
#include <stdio.h>int my_cp(const char* src_file, const char* dest_file){ FILE* in_file, * out_file; in_file = fopen(src_file, "rb"); if (in_file == NULL) { return 1; } out_file = fopen(dest_file,"wb"); if (out_file == NULL) { return .原创 2022-04-09 15:15:52 · 157 阅读 · 0 评论 -
C++-函数模板
#include <iostream>#include <fstream>#include <sstream>using namespace std;template<typename T>const int compare(const T& v1,const T& v2){ if (v1 < v2) return -1; if (v1 > v2) return 1; return 0;}templat.原创 2022-04-09 12:39:21 · 66 阅读 · 0 评论 -
C++-链式队列
main.c#include <iostream>#include "ListQueue.h"using namespace std;int main(){ ListQueue<int> myQ; myQ.enqueue(10); myQ.enqueue(20); myQ.enqueue(30); cout << myQ.getFront() << endl; myQ.dequeue(); cout << myQ.原创 2022-04-09 10:55:59 · 493 阅读 · 0 评论 -
C++-顺序循环队列
main.c#include <iostream>#include "Queue.h"using namespace std;int main(){ Queue<char> q(5); q.Push('A'); q.Push('B'); q.Push('C'); cout << q.Front() << ", " << q.Rear() << endl; q.Push('D'); q.Push(...原创 2022-04-08 21:09:00 · 394 阅读 · 0 评论 -
C++-抽象类和纯虚函数
#include <iostream>using namespace std;//抽象类,包含一个或多个抽象函数//不能实例化对象,只可以继承//继承之后必须把抽象函数覆盖//所继承的父类只要任何一个成员函数是虚的,子类的析构函数也应当是虚的class Shape{public: Shape() {} virtual ~Shape(){} virtual double GetArea() = 0; virtual double GetPerim() = 0; vi.原创 2022-04-08 14:42:26 · 195 阅读 · 0 评论 -
C++-派生类的构造函数和析构函数
构造和析构的顺序:构造函数:#include <iostream>using namespace std;class Base1{public: Base1(int i) { b1 = i; cout << "Base1的构造函数被调用" << endl; } void Print() const { cout << b1 << endl; }private: int b1;};clas..原创 2022-04-07 21:02:59 · 459 阅读 · 0 评论 -
C++-继承-多态
#include <iostream>using namespace std;class Animal{};class Dog :public Animal{};class Cat :public Animal{};class Item_base{public: //int x; Item_base(const std::string& book = "", double sales_price = 0.0) :isbn(book), pric.原创 2022-04-07 14:34:44 · 331 阅读 · 0 评论 -
C++-函数对象
一元函数对象:#include <iostream>#include <vector>#include <list>#include <algorithm>using namespace std;//一元函数对象,可以作为STL函数的参数struct absInt { int operator() (int val) { //一元函数操作符 return val < 0 ? -val : val; }};//模板函数te原创 2022-04-07 11:52:35 · 211 阅读 · 0 评论 -
C++-操作符重载
Salesitem.h/** This file contains code from "C++ Primer, Fifth Edition", by Stanley B.* Lippman, Josee Lajoie, and Barbara E. Moo, and is covered under the* copyright and warranty notices given in that book:** "Copyright (c) 2013 by Objectwrite, In原创 2022-04-06 12:53:23 · 1681 阅读 · 0 评论 -
C++-潜复制-深复制-智能指针
主函数:#include <iostream>#include "plain-ptr.h"#include "value-ptr.h"#include "smart-ptr.h"using namespace std; void test_AHasPtr() { int i = 42; AHasPtr p1(&i,42); AHasPtr p2=p1; cout << p2.get_ptr_val()<< endl; p1.set原创 2022-04-06 10:30:46 · 515 阅读 · 0 评论 -
C++-析构函数
#include <iostream>#include <vector>using namespace std;class NoName{public: NoName():pstring(new std::string),i(0),d(0) { //打开文件 //连接数据库 //动态分配内存 cout << "构造函数被调用了!" << endl; } ~NoName(); //析构函数只有一个,不能重载,没有参数,如果.原创 2022-04-05 19:59:36 · 549 阅读 · 0 评论 -
C++-复制构造函数-赋值操作符
#include <iostream>#include <vector>using namespace std;class Sales_item{public: Sales_item():units_sold(0),revenue(0.0) { cout << "默认的构造函数被调用了!" << endl; } Sales_item(const std::string &book) :isbn(book), unit.原创 2022-04-05 16:46:11 · 413 阅读 · 0 评论 -
C++-静态成员
#include <iostream>using namespace std;class Account{public: Account(std::string name,double money): owner(name),amount(money) {} double getAmount() const { return this->amount; } void applyint() { amount + amount * interestRate;.原创 2022-04-05 15:39:21 · 376 阅读 · 0 评论 -
C++-友元函数
#include <iostream>using namespace std;class Screen; //需要先声明Screen因为在Dog中引用了class Dog //这里的Dog必须在Screen前定义,因为在类的内部声明了Dog类内部的成员函数为友元,但函数的实现必须要在Screen类内部,因为函数内部操作了Screen的内部成员{public: int foo(Screen& screen); int koo(Screen& screen); .原创 2022-04-05 10:37:09 · 410 阅读 · 0 评论 -
C++-this指针-const重载
#include <iostream>using namespace std;class Person {public: //使用this指针,防止参数与成员变量混淆 Person(const std::string& name, const std::string& address) { this->name = name; this->address = address; } std::string getName() const .原创 2022-04-04 16:44:13 · 408 阅读 · 0 评论 -
C++-类
#include <iostream>using namespace std;class Sales_item{public: Sales_item(const std::string &book, unsigned units, double amount) //这里的string要用const修饰 :isbn(book), units_sold(units), revenue(amount) {} double avg_price() const { .原创 2022-04-04 13:36:39 · 305 阅读 · 0 评论