1. cout的用法:
#include<QDebug>
#define cout qDebug()<< "["<<__FILE__<< ":"<<__LINE__<< "]"
2.Halcon的引用:
#include "HalconCpp.h"
using namespace HalconCpp;
3.夸线程使用信号与槽:后面一定加上 Qt::BlockingQueuedConnection
connect(m_pCapImgProcs[0], SIGNAL(captured(HObject)), this, SLOT(on_imageProcess0(HObject)) , Qt::BlockingQueuedConnection);
connect(m_pCapImgProcs[1], SIGNAL(captured(HObject)), this, SLOT(on_imageProcess1(HObject)), Qt::BlockingQueuedConnection);
connect(this, SIGNAL(delImg0(HObject)), m_pArithmetic[0],SLOT(Recognise(HObject)), Qt::BlockingQueuedConnection);
4.需要用指针的地方用&代替。如下:
5.connect的各种形式:
//connect(this, &MainWindow::startImgCap0, m_pCapImgProcs[0], &ImageCaptureProcs::ImageCapture(0));
//connect(this, &MainWindow::startImgCap1, m_pCapImgProcs[1], &ImageCaptureProcs::ImageCapture(1));
connect(this,SIGNAL(startImgCap0(int)), m_pCapImgProcs[0], SLOT(ImageCapture(int)) ); //加了Qt::BlockingQueuedConnection 会阻塞窗口显示
connect(this, SIGNAL(startImgCap1(int)), m_pCapImgProcs[1], SLOT(ImageCapture(int)) );
6. Continue ,Break,Return这三个关键字的区别:
return :直接跳出当前的方法,返回到该调用的方法的语句处,继续执行
break:在循环体内结束整个循环过程
continue :结束本次的循环,直接进行下一次的循环
7.QString转HTuple:
HTuple str1=str.toStdString().c_str();
解决方案:
只要在末尾加一个空格,让最后一个中文汉字与双引号隔开,这样便不会再报错
如:
Log_Mess("设置低电平失败 ");
9 .获取系统时间
QString current_time = QDateTime::currentDateTime().toString("hh:mm:ss.zzz"); //("yyyy-MM-dd hh:mm:ss:zzz");
Log_Mess(current_time+QString("相机 %1 发送NG信号失败").arg(nCamID+1));
10.打开指定路径---做查看图片用
#include <QDesktopServices>
void MainWindow::on_pushButton_4_clicked()
{
QString curPath=QDir::currentPath(); //获取系统当前目录
QDesktopServices::openUrl(QUrl::fromLocalFile(curPath)); //支持中文路径
}