- // test_lambda.cpp : Defines the entry point for the console application.
- //
- //#include "stdafx.h"
- // even_lambda.cpp
- // compile with: /EHsc
- #include <algorithm>
- #include <iostream>
- #include <vector>
- using namespace std;
- struct tt
- {
- int a;
- int b;
- };
- void test_auto()
- {
- tt vv;
- auto ss = vv;
- printf("%d\n", sizeof(ss));
- }
- int main()
- {
- test_auto();
- // Create a vector object that contains 10 elements.
- vector<int> v;
- for (int i = 0; i < 10; ++i)
- {
- v.push_back(i);
- }
- // Count the number of even numbers in the vector by
- // using the for_each function and a lambda expression.
- int evenCount = 0;
- for_each(v.begin(), v.end(), [&evenCount] (int n) {
- cout << n;
- if (n % 2 == 0)
- {
- cout << " is even " << endl;
- // Increment the counter.
- evenCount++;
- }
- else
- {
- cout << " is odd " << endl;
- }
- });
- // Print the count of even numbers to the console.
- cout << "There are " << evenCount
- << " even numbers in the vector." << endl;
- }
作者: tao560532 时间: 2011-11-17 17:42
9G霸气
作者: hotpower 时间: 2011-11-17 17:55
上官和酒鬼都被9g用qt勾魂了
作者: 缥缈九哥 时间: 2011-11-19 17:58
哈哈,我把我的PMISP代码公开一下,希望大家指点,我第一次在PC上用C++做软件,做得丑陋,非常粗糙,很不好意思。很难为情的。电工做软件,就是那么个效果了。希望大家能帮助我提高。先谢谢大家 。[attach]86149[/attach],其中有一段关键协议代码。原厂不让我公开,我还是删除了。不影响程序的其它方面。
作者: 缥缈九哥 时间: 2011-11-20 08:58
没有人帮助我斧正斧正呀?
作者: hotpower 时间: 2011-11-22 13:24
俺有学习的打算,顶起来。
作者: 缥缈九哥 时间: 2011-11-24 23:12
欢迎菜农学习QT。
作者: 缥缈九哥 时间: 2011-12-15 12:19
本帖最后由 缥缈九哥 于 2011-12-15 12:32 编辑
//修改了一段代码 :
//读取文件BIN文件
memset(filebuffer,0xff,MAX_FILE_SIZE);
readfile.open(QIODevice::ReadOnly);
QDataStream in(&readfile);
in.setVersion(QDataStream::Qt_4_7);
in.readRawData(filebuffer, filesize);
readfile.close();
ui->textBrowser->clear();
for(i=0;i<filesize;)
{
str += num.sprintf("%08xh:",i);
for(quint8 j=0;j<16;j++)
{
str +=num.sprintf(" %02X",filebuffer&0xff);
if(((filebuffer&0xff) != 0xFF )&&((filebuffer&0xff) != 0))
{filetruesize=i+1;}
i++;
}
str +=" ;\n";
}
ui->textBrowser->append(str);
作者: lxyppc 时间: 2011-12-15 14:45
本帖最后由 lxyppc 于 2011-12-15 14:46 编辑
帮不上啥忙,帮你调了一下UI[attach]89658[/attach]
只修改了.ui文件,其它的文件没动
以前的代码在缩放时不能适应窗口大小的变化
缩小与放大窗口
[attach]89659[/attach][attach]89660[/attach]
调整后的代码
缩小与放大窗口
[attach]89661[/attach][attach]89662[/attach]
作者: 缥缈九哥 时间: 2011-12-17 10:42
谢谢。非常感谢。。。
作者: 缥缈九哥 时间: 2011-12-17 10:49
不过你修改的UI文件,感觉位置对齐有点乱了。或者说我的窗口直接禁止伸缩就好了。
作者: mcs8098 时间: 2011-12-20 12:34
支持:loveliness:
作者: 缥缈九哥 时间: 2011-12-29 17:53
不知道为什么,我做的ISP下载速度还是慢。我的等待超时及等待1MS源码如下 :
void sleep(unsigned int msec)
{
QTime dieTime = QTime::currentTime().addMSecs(msec);
while( QTime::currentTime() < dieTime )
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
}
qint8 MainWindow::wait_ack(uint ms ,qint8 ack)
{
uint i=ms;
while(i--)
{
sleep(1);
QByteArray temp = myCom->readAll();
if(!temp.isEmpty())
{
char *ch = temp.data();
if(ch[0]==ack) {return 1;}
else
if(ch[0]==0xff) {return 0;}
}
}
return 0;
}
作者: lxyppc 时间: 2011-12-30 09:45
不知道9G是如何操作COM口的,是同步的方式还是事件驱动的方式
这个wait_ack是运行在UI线程还是工作线程中
个人觉得用自定义的sleep函数不如Qt提供的sleep好用
作者: 缥缈九哥 时间: 2011-12-30 15:01
QT的SLEEP怎么用?我的串口模式? 我的串口就是这么配置的,然后就是读和写了,感觉这串口慢。别人的ISP程序,下载64K才20多秒。我的要30多秒。郁闷中。
if(myCom->open(QIODevice::ReadWrite)){
ui->statusBar->showMessage(tr("成功打开串口 ") + portName);
}else{
QMessageBox::critical(this, tr("打开失败"), tr("未能打开串口 ") + portName + tr("\n该串口设备不存在或已被占用"), QMessageBox::Ok);
//关闭串口
myCom->close();
delete myCom;
ui->statusBar->showMessage(tr("关闭串口")+ portName);
return;
}
//设置数据位
myCom->setDataBits(DATA_8);
//设置校验
myCom->setParity(PAR_NONE);
//设置停止位
myCom->setStopBits(STOP_1);
//数据流控制设置
myCom->setFlowControl(FLOW_OFF);
do_all_again:
//设置波特率
myCom->setBaudRate(BAUD9600);
作者: e2zone 时间: 2012-1-4 22:52
牛X!
作者: 缥缈九哥 时间: 2012-1-9 16:56
wait_ack(uint ms ,qint8 ack)
等待时间太长了,为知道怎么改架构才对。
作者: lwslws201 时间: 2012-1-9 19:32
:victory: 顶呀!
作者: 江枫渔火 时间: 2012-1-9 21:10
霸气外露
用QT应该还有个好处,移植性比VC好~
QT本是LINUX世界的玩物~
作者: yulri 时间: 2012-2-9 14:15
先记下了!!
作者: 王紫豪 时间: 2012-3-19 01:04
QT非常不错,支持下
作者: 缥缈九哥 时间: 2012-3-19 10:02
有人告诉一下我如何 才能加快速度吗?这个睡眠太浪费时间了。
void sleep(unsigned int msec)
{
QTime dieTime = QTime::currentTime().addMSecs(msec);
while( QTime::currentTime() < dieTime )
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
}
作者: 缥缈九哥 时间: 2012-3-29 22:09
好久没有玩QT了,谁介绍一个开发QT的HID驱动的例子?
作者: 呆板书生 时间: 2012-3-29 22:10
顶,准备学习学习
作者: lxyppc 时间: 2012-3-30 12:17
好久没有玩QT了,谁介绍一个开发QT的HID驱动的例子?
缥缈九哥 发表于 2012-3-29 22:09 
HID在Windows下面调用SetupAPI相关的函数就可以了
作者: 缥缈九哥 时间: 2012-3-31 01:24
谢谢lxyppc。
作者: jinjing999 时间: 2012-6-21 16:35
楼主威猛。留下脚印
作者: 缥缈九哥 时间: 2012-10-28 11:28
好久没有玩QT了,差不多忘记了。重新温习一下。
作者: 缥缈九哥 时间: 2013-4-24 11:35
顶起
作者: renxiaolin 时间: 2017-3-13 14:35
这个不支持不可以
欢迎光临 21ic电子技术开发论坛 (https://bbs.21ic.com/) |
Powered by Discuz! X3.5 |