
C++
甩你十万八千里
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
鼠标事件 获取鼠标坐标及点击事件
statusBar()->showMessage(tr(“释放在:”)+str,3000);statusBar()->showMessage(tr(“左键:”)+str);statusBar()->showMessage(tr(“右键:”)+str);statusBar()->showMessage(tr(“中键:”)+str);原创 2023-06-17 18:13:21 · 1059 阅读 · 0 评论 -
.txt文件内容按行读取
char buf[1024];std::string ConfigFile = “GadgetronConfig.txt”;FILE* fp = fopen(ConfigFile.c_str(), “r”);while (fgets(buf, sizeof(buf), fp)){printf(“%s\n”, buf); std::string str = buf; string::size_type idx; std::string subString; subString = "add原创 2022-04-06 19:36:53 · 639 阅读 · 0 评论 -
将QString内容写入.txt文件中
QString str = "";QFile myfile("D:/test.txt");myfile.open(QIODevice::WriteOnly | QIODevice::Append);for (int i = 0; i< reception_message.m_message_length; i++){ str += QString("%1 ").arg(reception_message.m_message_data[i]);}myfile.write(str.t原创 2022-02-25 16:19:57 · 1722 阅读 · 0 评论 -
QT 十六进制整数变为字符串自动补0 && 十进制补零
QString str = QString("%1").arg(outChar&0xFF,2,16,QLatin1Char(‘0’));int a=0001;QString str = QString("%1").arg(a,4,10,QLatin1Char(‘0’));原创 2022-02-10 15:20:16 · 1688 阅读 · 0 评论 -
屏蔽任务栏
GetKeyboardMouseDeviceController()->showTaskWindow(false);//屏蔽任务栏原创 2021-06-29 10:32:00 · 199 阅读 · 0 评论 -
杀死当前进程
本例子实现检测当前进程ID,并将当前进程关闭///杀死当前进程//*/void KillCurrentProcess(){HANDLE hSnapshot = NULL;hSnapshot = GetProcessHandleByID(GetCurrentProcessId());if (hSnapshot){ TerminateProcess(hSnapshot, 0); ...原创 2019-09-27 14:20:57 · 295 阅读 · 0 评论 -
C++中struct和class定义类区别
C++中struct和class定义类区别有一种常见的误解认为用struct保留字定义的类与用class定义的类有很大的区别。唯一的不同只是默认的成员保护级别和默认的派生保护级别,没有其他的区别。用class定义的类,默认的成员访问级别为private。struct定义的类成员默认访问级别是public。使用class关键字定义的派生类默认具有private继承,而用struct关键...转载 2019-04-27 11:05:54 · 1487 阅读 · 0 评论 -
C/C++中的static用法总结
C中:static修饰函数中的变量(栈变量):改变变量的生存期,作用域不变仍为所在函数。 只被初始化一次。static修饰全局变量:限制全局变量只能被模块内访问,不可以在别的模块中用extern声明调用。static修饰函数:作用与修饰全局变量类似,也是限制该函数只能在模块内访问,不能再别的模块中用extern声明调用。例如:文件a.cstatic int i; //只...转载 2019-04-27 11:08:51 · 305 阅读 · 0 评论 -
如何优化代码中大量的if/else,switch/case?
前言随着项目的迭代,代码中存在的分支判断可能会越来越多,当里面涉及到的逻辑比较复杂或者分支数量实在是多的难以维护的时候,我们就要考虑下,有办法能让这些代码变得更优雅吗?正文使用枚举这里我们简单的定义一个表示状态的枚举。public enum Status {NEW(0),RUNNABLE(1),RUNNING(2),BLOCKED(3),DEAD(4);public int stat...转载 2019-05-05 19:07:43 · 246 阅读 · 0 评论 -
Qt中将每个汉字转成2个字节长度 格式转换gbk
QString str = “我是中国人123”;char gbk[64];QByteArray ba = QTextCodec::codecForName(“GBK”)->fromUnicode(str);//unicodezhuangGBK之间的转换器memset(gbk, 0, sizeof(gbk));//初始化为0strcpy(gbk, ba.data());const ...原创 2019-05-06 09:04:52 · 1438 阅读 · 0 评论 -
Qt中将控件放置在鼠标坐标指定位置
QLabel *m_tip_prompt = NULL;m_tip_prompt=new QLabel;QPoint aaa = cursor().pos();//获取鼠标位置this->m_tip_prompt->setText(“测试”);this->m_tip_prompt->raise();this->m_tip_prompt->move(aa...原创 2019-05-06 09:11:14 · 2164 阅读 · 2 评论 -
判断字符串是否为纯数字和字母
/***********************************************************************// 判断字符串是否为纯数字和字母 //******************************************************...原创 2019-05-08 17:31:02 · 2939 阅读 · 0 评论 -
QTableView点击表头进行排序
QTableView点击表头进行排序void SortByColumnSlot(int column){static bool bStata = true;ui.m_PatientCheckTableView->sortByColumn(column, bStata ? Qt::AscendingOrder : Qt::DescendingOrder);//升序、降序SetChec...原创 2019-05-25 09:48:42 · 1571 阅读 · 0 评论 -
C++ STL详解
C++ STL详解转载自:http://www.cnblogs.com/shiyangxt/archive/2008/09/11/1289493.html一、STL简介STL(Standard Template Library,标准模板库)是惠普实验室开发的一系列软件的统称。它是由Alexander Stepanov、Meng Lee和David R Musser在惠普实验室工作时所开发出来...转载 2019-04-27 11:01:31 · 607 阅读 · 0 评论