随笔分类 - 软件技术
编程语言,计算机软件相关
摘要:std::vector<int> arr = {0,1,2,3,4,5 }; auto it = std::find(arr.begin(), arr.end(), 3); auto index = it - arr.begin(); std::cout << "[" << index << "]"
阅读全文
摘要:如果有一个基类: class Dog { public: virtual ~Dog() {} void show(int a) { cout << "我是一只狗!" << a << "岁" << '\n'; } void mysong() { cout << "哈哈哈..." << '\n'; }
阅读全文
摘要:服务端 // 服务端 #include <cstdio> #include <cstdlib> #include <WinSock2.h> #include <Ws2tcpip.h> // inet_pton 函数所在头文件 #pragma comment(lib, "ws2_32.lib") //
阅读全文
摘要:QTextCursor cursor = ui.textEdit_Recive->textCursor(); cursor.movePosition(QTextCursor::End); // 移动光标到文档末尾 ui.textEdit_Recive->setTextCursor(cursor);
阅读全文
摘要:对 C 语言构成要素的一点思考: 数组 // 泛指容器 枚举 // 与数组配合 结构体 指针 函数
阅读全文
摘要:void MyWidgets::setWindowTopFixStyle(QString title, QWidget * widget) { widget->setWindowTitle(title); widget->setWindowFlags(windowFlags() & ~Qt::Win
阅读全文
摘要:基于形状轮廓的模板匹配 https://www.cnblogs.com/ybqjymy/p/14445887.html // 基于形状的模板匹配 https://blog.csdn.net/weixin_45672157/article/details/134998447 // Halcon 模板匹
阅读全文
摘要:Demo: class Animal { public: Animal() { cout << "animal..." << endl; } virtual ~Animal() { cout << "~animal..." << endl; } virtual void ShowAnimal() =
阅读全文
摘要:class CatBase { public: CatBase() { show1(); } ~CatBase() { } //virtual void show1() = 0; // 如果不实现,运行时会错误 virtual void show1() { cout << "cat base ...
阅读全文
摘要:可以自定义一个类QtImageLabel继承于QLabel,重写paintEvent事件划线,写文字等。如果用 ui 设计,将 QLabel 控件提升为 QtImageLabel 类型即可。 QtImageLabel.h protected: void paintEvent(QPaintEvent
阅读全文
摘要:一般这样子: // 跟随比例变化 ui->label->setScaledContents(true); QPixmap pixmap("./01.jpg"); //pixmap.load("./01.jpg"); // 让图片大小适应控件大小, 如果不需要,可以直接显示原图 QPixmap s_i
阅读全文
摘要:给子窗口设置以下属性: setAttribute(Qt::WA_QuitOnClose,false); 参考: https://blog.csdn.net/qq_40754866/article/details/109217799
阅读全文
摘要:执行字符集: #pragma execution_character_set("utf-8")
阅读全文
摘要:以+运算符重载为例: #include <iostream> #include <string> // 前置声明是必须的 namespace mydog { class Dog; } namespace myadd { mydog::Dog operator+(const mydog::Dog do
阅读全文
摘要:int retVal(int &&v) { cout << "右值引用:"; return v; } int retVal(int &v) { cout << "左值引用:"; return v; } int retVal(const int &v) { cout << "const 左值引用:";
阅读全文
摘要:既有拷贝构造又有移动构造 这个比较好理解,普通的函数匹配规则就可以。右值移动,左值拷贝。 ——《C++ Primer》 P477 我们不能隐式地将一个右值引用绑定到一个左值。 有拷贝构造但没有移动构造 这种情况,右值也会被拷贝。 如果一个类没有移动构造函数,函数匹配规则保证该类型的对象会被拷贝,即使
阅读全文
摘要:若有多个信号绑定同一个槽: QCheckBox *ckb = new QCheckBox(this); connect(ckb, &QCheckBox::clicked, this, &MyWidget::ckb_clicked); 槽函数中判断发送者对象: void MyWidget::ckb_c
阅读全文