QT + halcon混合编程 一个读取图像的项目4

在前面的项目上进行修改,修改了两个界面之间的信息传递(自定义信号senddata(),emit发送信号,自定义接受信号的槽函数gendata())

需要实现的主要功能:1.读取指定的图像 2. 读取连接的相机图像  3.快捷菜单图像的保存 4.相机的帧捕获器参数设置

项目环境: win10        HALCON18.11        Qt 514

直接上运行结果图(参数设置实现了前面的8个,后面三个(帧率,外部触发,断开)是没有响应的)。

QT + halcon混合编程 一个读取图像的项目4_第1张图片

 QT + halcon混合编程 一个读取图像的项目4_第2张图片

 QT + halcon混合编程 一个读取图像的项目4_第3张图片

  项目文件(.pro)

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11

# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
    main.cpp \
    subwindow.cpp \
    widget.cpp

HEADERS += \
    subwindow.h \
    widget.h

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target


#halcon配置代码,已经将include、lib拷贝到项目之下
win32: LIBS += -L$$PWD/lib/x64-win64/ -lhalcon
win32: LIBS += -L$$PWD/lib/x64-win64/ -lhalconc
win32: LIBS += -L$$PWD/lib/x64-win64/ -lhalconcpp
win32: LIBS += -L$$PWD/lib/x64-win64/ -lhalconcppxl
win32: LIBS += -L$$PWD/lib/x64-win64/ -lhalconcxl
win32: LIBS += -L$$PWD/lib/x64-win64/ -lhalconxl
win32: LIBS += -L$$PWD/lib/x64-win64/ -lhdevenginecpp
win32: LIBS += -L$$PWD/lib/x64-win64/ -lhdevenginecppxl
win32: LIBS += -L$$PWD/lib/x64-win64/ -llibiomp5md

INCLUDEPATH += $$PWD/include
DEPENDPATH += $$PWD/include

 头文件Widget.h

#ifndef WIDGET_H
#define WIDGET_H

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include
#include
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include "halconcpp/HalconCpp.h"
#include "Halcon.h"

//#include "SubWindow.h"
#include "subwindow.h"
using namespace HalconCpp;


#pragma execution_character_set("utf-8") //支持中文

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();



private:
    QLabel *label;
    QPushButton *btn1;
    QPushButton *btn2;
    QPushButton *btn3;
    QPushButton *btn4;
    QPushButton *btn5;

    HTuple  hv_AcqHandle,hv_WindowHandle;
    HObject  ho_Image;
    HTuple  hv_Width, hv_Height;
    Hlong windID;
    QTimer *timer;
    Hlong  MainWndID;


    QTabWidget *tabwidget;
    QWidget *tab1;
    QWidget *tab2;
    QTextEdit *qle;
    QComboBox *cbox;

    HTuple  hv_Information, hv_ValueList;


    QMenu *m_pMenu;
    QAction *m_pa1,*m_pa2;

    Subwindow *subwin;

    void createWidget();
    void createMyMenu();


    //int testvalue = 0;
signals:
    //void mySignal();
    void mySignal();

private slots:
    void on_clicked1();
    void on_clicked2();
    void on_clicked3();
    void on_clicked4();


    void on_clicked5();

    void camera();


    void onMenu1Event();
    void onMenu2Event();

    //void mySlot();
    //void getData(QString str,int value);
    void getData(int,int,int,int,int,int,int,QString,double,QString,QString);

protected:
    void mousePressEvent(QMouseEvent * event);//鼠标单击事件

};
#endif // WIDGET_H

 C++文件Widget.cpp

#include "widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
{
    //创建界面
    createWidget();

    //创建快捷菜单
    createMyMenu();

    subwin = new Subwindow();

    //连接子页面信号和主页面的槽
    connect(subwin,SIGNAL(sendData(int,int,int,int,int,int,int,QString,double,QString,QString)),
            this,SLOT(getData(int,int,int,int,int,int,int,QString,double,QString,QString)));



    timer = new QTimer(this);

    connect(timer,SIGNAL(timeout()),this,SLOT(camera()));


    connect(this->btn1,SIGNAL(clicked()),this,SLOT(on_clicked1()));
    connect(this->btn2,SIGNAL(clicked()),this,SLOT(on_clicked2()));
    connect(this->btn3,SIGNAL(clicked()),this,SLOT(on_clicked3()));
    connect(this->btn4,SIGNAL(clicked()),this,SLOT(on_clicked4()));


    connect(m_pa1,SIGNAL(triggered()),this,SLOT(onMenu1Event()));
    connect(m_pa2,SIGNAL(triggered()),this,SLOT(onMenu2Event()));


    connect(this->btn5,SIGNAL(clicked()),this,SLOT(on_clicked5()));


}

Widget::~Widget()
{
}

void Widget::createWidget(){

    this->setFixedSize(1000,575);
    this->setWindowTitle("图像读取");

    label = new QLabel(this);
    label->setGeometry(350,25,600,500);

    MainWndID = (Hlong)this->label->winId();
    OpenWindow(0, 0, label->width(), label->height(), MainWndID,
               "visible", "", &hv_WindowHandle);
    HDevWindowStack::Push(hv_WindowHandle);

    qle = new QTextEdit(this);
    //qle->setGeometry(25,325,300,200);
    qle->setGeometry(25,330,300,195);
    qle->setReadOnly(true);

    tabwidget = new QTabWidget(this);
    tab1 = new QWidget;
    tab2 = new QWidget;
    //tab3 = new QWidget;
    tabwidget->addTab(tab1, "读取指定图像");
    tabwidget->addTab(tab2, "读取相机图像");
    tabwidget->setGeometry(25, 25, 300, 300);
    tabwidget->setTabShape(QTabWidget::Triangular);

    QVBoxLayout *vbox1 = new QVBoxLayout;
    //vbox1->setAlignment(Qt::AlignTop|Qt::AlignHCenter);
    vbox1->setAlignment(Qt::AlignCenter);
    tab1->setLayout(vbox1);

    btn1 = new QPushButton();
    btn1->setFixedSize(100,50);
    btn1->setText("选择图片");
    vbox1->addWidget(btn1);



    QVBoxLayout *vbox2 = new QVBoxLayout;
    vbox2->setAlignment(Qt::AlignHCenter);
    tab2->setLayout(vbox2);

    QVBoxLayout *vbox3 = new QVBoxLayout;
    vbox3->setAlignment(Qt::AlignHCenter);
    vbox3->setSpacing(10);

    QWidget *qw0 = new QWidget;
    qw0->setLayout(vbox3);
    vbox2->addWidget(qw0);

    cbox = new QComboBox();
    cbox->setFixedSize(200,35);
    vbox3->addWidget(cbox);

    QGridLayout *gbox = new QGridLayout;
    gbox->setAlignment(Qt::AlignTop);
    gbox->setSpacing(35);

    QWidget *qw1 = new QWidget;
    qw1->setLayout(gbox);
    vbox2->addWidget(qw1);



    btn2 = new QPushButton();
    btn2->setFixedSize(100,50);
    btn2->setText("打开相机");
    btn2->setEnabled(false);
    gbox->addWidget(btn2,1,0,1,1);
    //vbox2->addWidget(btn2);

    btn3 = new QPushButton();
    btn3->setFixedSize(100,50);
    btn3->setText("关闭相机");
    btn3->setEnabled(false);
    gbox->addWidget(btn3,1,1,1,1);
    //vbox2->addWidget(btn3);

    btn4 = new QPushButton();
    btn4->setFixedSize(100,50);
    btn4->setText("检测相机");
    gbox->addWidget(btn4,0,0,1,1);
    //gridlayout->addWidget(xmval1,0,1,1,1);
    //vbox2->addWidget(btn4);

    btn5 = new QPushButton();
    btn5->setFixedSize(100,50);
    btn5->setText("配置参数");
    gbox->addWidget(btn5,0,1,1,1);


}


void Widget::createMyMenu(){
    //创造菜单对象
    m_pMenu = new QMenu(this);
    m_pa1 = m_pMenu->addAction("另存为");
    m_pa2 = m_pMenu->addAction("退出");
}


void Widget::mousePressEvent(QMouseEvent *event)
{
    //在鼠标右击的地方显示菜单
    /*
    if(e->button()==Qt::RightButton)
    {
        m_pMenu->exec(cursor().pos());
    }*/
    if(label->geometry().contains(this->mapFromGlobal(QCursor::pos())) //鼠标是否在界面上
            &&event->button()==Qt::RightButton)
    {
        qDebug() << "右键:快捷菜单" ;
        m_pMenu->exec(cursor().pos());
    }
}

void Widget::onMenu1Event(){
    //QMessageBox::information(this,"注意","保存图片");

    try
    {
        qDebug() << "另图片为";
        QString filename = QFileDialog::getSaveFileName(this,tr("Save Image"),"",tr("Images (*.png *.bmp *.jpg)")); //选择路径
        qDebug() << "图片路径:"<close();
    qDebug() << "退出";
    close();
}


void Widget::on_clicked1(){
    qDebug() << "按下了1号按钮,读取图片";
    try
    {
        QString file_name;
        file_name = QFileDialog::getOpenFileName(this,tr("open  file"),".",tr("Video Files(*.bmp *.jpg *.pbm *.pgm *.png *.ppm *.xbm *.xpm)"));

        qle->setText("读取图像:"+file_name);

        QByteArray ba = file_name.toLatin1();
        const char *str = ba.data();
        HTuple  ImageName(str);

        ReadImage(&ho_Image, ImageName);
        GetImageSize(ho_Image, &hv_Width, &hv_Height);
        SetPart(hv_WindowHandle, 0, 0, hv_Height, hv_Width);
        DispObj(ho_Image, HDevWindowStack::GetActive());
    }
    catch (HException &HDevExpDefaultException)
    {
        HTuple  hv_Exception;
        HDevExpDefaultException.ToHTuple(&hv_Exception);
    }
}

void Widget::on_clicked2(){
    qDebug() << "按下了2号按钮,打开相机";
    qle->setText("打开相机");
    //timer->start(20);//定时器开始工作,参数影响帧率
    timer->start(20);//定时器开始工作,参数影响帧率
    //Image Acquisition 01: Code generated by Image Acquisition 01
    /*
    OpenFramegrabber("DirectShow", 1, 1, 0, 0, 0, 0, "default", 8, "rgb", -1, "false",
                     "default", "[0] USB2.0 PC CAMERA", 0, -1, &hv_AcqHandle);*/

    try
    {
        int curIndex = cbox->currentIndex();

        OpenFramegrabber("DirectShow", 1, 1, 0, 0, 0, 0, "default", 8, "rgb", -1, "false",
                         "default", hv_ValueList[curIndex], 0, -1, &hv_AcqHandle);

        //SetFramegrabberParam(hv_AcqHandle, "brightness", 0);
        //SetFramegrabberParam(hv_AcqHandle, "contrast", 28);

        GrabImageStart(hv_AcqHandle, -1);

        //    在openwindow前先抓取一帧图片
        GrabImage(&ho_Image,hv_AcqHandle);
        btn3->setEnabled(true);
        btn2->setEnabled(false);
    }
    catch (HException &HDevExpDefaultException)
    {
        HTuple  hv_Exception;
        HDevExpDefaultException.ToHTuple(&hv_Exception);
    }


}

void Widget::on_clicked3(){
    qDebug() << "按下了3号按钮,关闭相机";
    qle->setText("关闭相机");
    timer->stop();
    CloseFramegrabber(hv_AcqHandle);
    btn3->setEnabled(false);
    btn2->setEnabled(true);
}

void Widget::camera()
{
    GrabImage(&ho_Image, hv_AcqHandle);
    GetImageSize(ho_Image, &hv_Width, &hv_Height);
    SetPart(hv_WindowHandle, 0, 0, hv_Height, hv_Width);
    if(HDevWindowStack::IsOpen())
    {
        DispObj(ho_Image,HDevWindowStack::GetActive());
    }
    //WaitSeconds(0.1);
}

void Widget::on_clicked4(){
    qDebug() << "按下了4号按钮,检测相机";

    try
    {
        InfoFramegrabber("DirectShow", "device", &hv_Information, &hv_ValueList);
        HString str1 = hv_Information.S();

        int num = hv_ValueList.Length();
        QString result = "检测到"+QString::number(num)+"个相机"+"\n"+str1.Text()+"\n";
        // HString str2 = "";
        cbox->clear();
        for (int i = 0; i < num; ++i) {
            HString str2 = hv_ValueList[i].S();
            cbox->addItem(QString(str2));
            result = result + str2.Text()+"\n";
        }

        qDebug()<setText(result);
        btn2->setEnabled(true);
    }
    catch (HException &HDevExpDefaultException)
    {
        HTuple  hv_Exception;
        HDevExpDefaultException.ToHTuple(&hv_Exception);
        qle->setText("没检测到相机");
    }
}


void Widget::on_clicked5(){
    qDebug() << "按下了5号按钮,配置参数";
    //testvalue = 100;

    //Subwindow *subwin = new Subwindow();
    subwin->show();
}



void Widget::getData(int value1,int value2,int value3,int value4,int value5,int value6,
                     int value7,QString value8,double value9,QString value10,QString value11)
{

    qDebug() <<"设置帧抓取器参数";
    //1

    SetFramegrabberParam(hv_AcqHandle, "grab_timeout", HTuple(value1));

    //2
    //SetFramegrabberParam(hv_AcqHandle, "brightness", 161);
    SetFramegrabberParam(hv_AcqHandle, "brightness", HTuple(value2));

    //3
    //SetFramegrabberParam(hv_AcqHandle, "contrast", 255);
    SetFramegrabberParam(hv_AcqHandle, "contrast", HTuple(value3));

    //4
    //SetFramegrabberParam(hv_AcqHandle, "hue", 53);
    SetFramegrabberParam(hv_AcqHandle, "hue", HTuple(value4));

    //5
    //SetFramegrabberParam(hv_AcqHandle, "saturation", 255);

    SetFramegrabberParam(hv_AcqHandle, "saturation", HTuple(value5));

    //6
    //SetFramegrabberParam(hv_AcqHandle, "sharpness", 7);
    SetFramegrabberParam(hv_AcqHandle, "sharpness", HTuple(value6));

    //7
    //SetFramegrabberParam(hv_AcqHandle, "gamma", 6);
    SetFramegrabberParam(hv_AcqHandle, "gamma", HTuple(value7));

    //8
    //HTuple(
    //SetFramegrabberParam(hv_AcqHandle, "backlight_compensation", "on");
    QByteArray Qa8 = value8.toLatin1();
    const char *str8 = Qa8.data();
    HTuple  fg8(str8);
    SetFramegrabberParam(hv_AcqHandle, "backlight_compensation", fg8);
    //SetFramegrabberParam(hv_AcqHandle, "backlight_compensation", "off");

    //9
    //SetFramegrabberParam(hv_AcqHandle, "frame_rate", 30.0);

    //10
    //SetFramegrabberParam(hv_AcqHandle, "external_trigger", "false");

    //11
    SetFramegrabberParam(hv_AcqHandle, "disconnect_graph", "false");
}

 subwindow.h

#ifndef SUBWINDOW_H
#define SUBWINDOW_H

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include
#include
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include "halconcpp/HalconCpp.h"
#include "Halcon.h"

#include 
#include 
#include 
//#include "widget.h"


using namespace HalconCpp;

#pragma execution_character_set("utf-8") //支持中文

class Subwindow : public QWidget
{
    Q_OBJECT

public:
    explicit Subwindow(QWidget *parent = nullptr);
    ~Subwindow();

    int fg_value1 = 5000;
    int fg_value2 = 128;
    int fg_value3 = 140;
    int fg_value4 = 0;
    int fg_value5 = 80;
    int fg_value6 = 1;
    int fg_value7 = 4;
    QString fg_value8 = "on";
    double fg_value9 = 30;
    QString fg_value10 = "false";
    QString fg_value11 = "false";


private:
    //QLineEdit *qle1;
    //QPushButton *Btn;
    //QLineEdit *qle1;
//signals:
//    void sendData(QString);//发送数据的信号
    //QLineEdit *input1;


    void createWinow();
    QButtonGroup *groupButton8;
    QComboBox *input9;
signals:
    //void sendData(QString);//发送数据的信号
    //void sendData(QString,int);//发送数据的信号
    void sendData(int,int,int,int,int,int,int,QString,double,QString,QString);//发送数据的信号


private slots:
    void changefgv1(int value);
    void changefgv2(int value);
    void changefgv3(int value);
    void changefgv4(int value);
    void changefgv5(int value);
    void changefgv6(int value);
    void changefgv7(int value);

    void changefgv8();

    //void changefgv9(double value);
    void changefgv9(double value);

    void changefgv10(QString value);
    void changefgv11(QString value);


};


#endif // SUBWINDOW_H

subwindow.cpp

//#include "SubWindow.h"
#include "subwindow.h"

Subwindow::Subwindow(QWidget *parent) :
    QWidget(parent)
{

    createWinow();


}

Subwindow::~Subwindow()
{

}

void Subwindow::createWinow()
{


    this->setWindowTitle("配置参数");
    this->setFixedSize(800,360);

    /
    QLabel *ql1 = new QLabel(this);
    ql1->setText("grab timeout:");
    ql1->setWordWrap(true);
    ql1->adjustSize();
    ql1->setAlignment(Qt::AlignRight|Qt::AlignTop);
    ql1->setGeometry(25,40,100,50);

    QSpinBox *input1 = new QSpinBox(this);
    input1->setMaximum(9999);
    input1->setMinimum(0);
    input1->setSingleStep(10);
    input1->setValue(5000);
    input1->setGeometry(125,40,100,30);

    connect(input1,SIGNAL(valueChanged(int)),this,SLOT(changefgv1(int)));




    ///



    QLabel *ql2 = new QLabel(this);
    ql2->setText("brightness:");
    ql2->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
    ql2->setGeometry(425,40,100,30);

    QSpinBox *input2_0 = new QSpinBox(this);
    input2_0->setMaximum(255);
    input2_0->setMinimum(0);
    input2_0->setSingleStep(1);
    input2_0->setValue(128);
    input2_0->setGeometry(525,40,100,30);


    QSlider *input2_1 = new QSlider(this);
    input2_1->setMaximum(255);
    input2_1->setMinimum(0);
    input2_1->setSingleStep(1);
    input2_1->setValue(128);
    input2_1->setOrientation(Qt::Horizontal);
    input2_1->setTickPosition(QSlider::TicksBothSides);
    input2_1->setGeometry(625,40,100,30);


    connect(input2_0, SIGNAL(valueChanged(int)), input2_1, SLOT(setValue(int)));
    connect(input2_1, SIGNAL(valueChanged(int)), input2_0, SLOT(setValue(int)));

    connect(input2_0,SIGNAL(valueChanged(int)),this,SLOT(changefgv2(int)));
    //connect(input2_0,SIGNAL(valueChanged(int)),this,SLOT(changefgv(int)));

    ///
    QLabel *ql3 = new QLabel(this);
    ql3->setText("contrast:");
    ql3->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
    ql3->setGeometry(25,90,100,30);

    QSpinBox *input3_0 = new QSpinBox(this);
    input3_0->setMaximum(255);
    input3_0->setMinimum(0);
    input3_0->setSingleStep(1);
    input3_0->setValue(140);
    input3_0->setGeometry(125,90,100,30);


    QSlider *input3_1 = new QSlider(this);
    input3_1->setMaximum(255);
    input3_1->setMinimum(0);
    input3_1->setSingleStep(1);
    input3_1->setValue(140);
    input3_1->setOrientation(Qt::Horizontal);
    input3_1->setTickPosition(QSlider::TicksBothSides);
    input3_1->setGeometry(225,90,100,30);


    connect(input3_0, SIGNAL(valueChanged(int)), input3_1, SLOT(setValue(int)));
    connect(input3_1, SIGNAL(valueChanged(int)), input3_0, SLOT(setValue(int)));

    connect(input3_0,SIGNAL(valueChanged(int)),this,SLOT(changefgv3(int)));

    //
    QLabel *ql4 = new QLabel(this);
    ql4->setText("hue:");
    ql4->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
    ql4->setGeometry(425,90,100,30);

    QSpinBox *input4_0 = new QSpinBox(this);
    input4_0->setMaximum(127);
    input4_0->setMinimum(-127);
    input4_0->setSingleStep(1);
    input4_0->setValue(0);
    input4_0->setGeometry(525,90,100,30);


    QSlider *input4_1 = new QSlider(this);
    input4_1->setMaximum(127);
    input4_1->setMinimum(-127);
    input4_1->setSingleStep(1);
    input4_1->setValue(0);
    input4_1->setOrientation(Qt::Horizontal);
    input4_1->setTickPosition(QSlider::TicksBothSides);
    input4_1->setGeometry(625,90,100,30);


    connect(input4_0, SIGNAL(valueChanged(int)), input4_1, SLOT(setValue(int)));
    connect(input4_1, SIGNAL(valueChanged(int)), input4_0, SLOT(setValue(int)));

    connect(input4_0,SIGNAL(valueChanged(int)),this,SLOT(changefgv4(int)));

    ///
    QLabel *ql5 = new QLabel(this);
    ql5->setText("saturation:");
    ql5->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
    ql5->setGeometry(25,140,100,30);

    QSpinBox *input5_0 = new QSpinBox(this);
    input5_0->setMaximum(255);
    input5_0->setMinimum(0);
    input5_0->setSingleStep(1);
    input5_0->setValue(80);
    input5_0->setGeometry(125,140,100,30);


    QSlider *input5_1 = new QSlider(this);
    input5_1->setMaximum(255);
    input5_1->setMinimum(0);
    input5_1->setSingleStep(1);
    input5_1->setValue(80);
    input5_1->setOrientation(Qt::Horizontal);
    input5_1->setTickPosition(QSlider::TicksBothSides);
    input5_1->setGeometry(225,140,100,30);


    connect(input5_0, SIGNAL(valueChanged(int)), input5_1, SLOT(setValue(int)));
    connect(input5_1, SIGNAL(valueChanged(int)), input5_0, SLOT(setValue(int)));

    connect(input5_0,SIGNAL(valueChanged(int)),this,SLOT(changefgv5(int)));
    //
    QLabel *ql6 = new QLabel(this);
    ql6->setText("sharpness:");
    ql6->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
    ql6->setGeometry(425,140,100,30);

    QSpinBox *input6_0 = new QSpinBox(this);
    input6_0->setMaximum(15);
    input6_0->setMinimum(0);
    input6_0->setSingleStep(1);
    input6_0->setValue(1);
    input6_0->setGeometry(525,140,100,30);


    QSlider *input6_1 = new QSlider(this);
    input6_1->setMaximum(15);
    input6_1->setMinimum(0);
    input6_1->setSingleStep(1);
    input6_1->setValue(1);
    input6_1->setOrientation(Qt::Horizontal);
    input6_1->setTickPosition(QSlider::TicksBothSides);
    input6_1->setGeometry(625,140,100,30);


    connect(input6_0, SIGNAL(valueChanged(int)), input6_1, SLOT(setValue(int)));
    connect(input6_1, SIGNAL(valueChanged(int)), input6_0, SLOT(setValue(int)));

    connect(input6_0,SIGNAL(valueChanged(int)),this,SLOT(changefgv6(int)));
    /
    QLabel *ql7 = new QLabel(this);
    ql7->setText("gamma:");
    ql7->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
    ql7->setGeometry(25,190,100,30);

    QSpinBox *input7_0 = new QSpinBox(this);
    input7_0->setMaximum(8);
    input7_0->setMinimum(1);
    input7_0->setSingleStep(1);
    input7_0->setValue(4);
    input7_0->setGeometry(125,190,100,30);


    QSlider *input7_1 = new QSlider(this);
    input7_1->setMaximum(8);
    input7_1->setMinimum(1);
    input7_1->setSingleStep(1);
    input7_1->setValue(4);
    input7_1->setOrientation(Qt::Horizontal);
    input7_1->setTickPosition(QSlider::TicksBothSides);
    input7_1->setGeometry(225,190,100,30);


    connect(input7_0, SIGNAL(valueChanged(int)), input7_1, SLOT(setValue(int)));
    connect(input7_1, SIGNAL(valueChanged(int)), input7_0, SLOT(setValue(int)));

    connect(input7_0,SIGNAL(valueChanged(int)),this,SLOT(changefgv7(int)));
    /
    QLabel *ql8 = new QLabel(this);
    ql8->setText("backlight compensation:");
    ql8->setWordWrap(true);
    ql8->adjustSize();
    ql8->setAlignment(Qt::AlignRight|Qt::AlignTop);
    ql8->setGeometry(425,190,100,50);



    QRadioButton *radio1 = new QRadioButton(tr("on"),this);
    QRadioButton *radio2 = new QRadioButton(tr("off"),this);
    radio1->setGeometry(530,190,100,30);
    radio2->setGeometry(625,190,100,30);

    //QButtonGroup *groupButton8 = new QButtonGroup();
    groupButton8 = new QButtonGroup();
    groupButton8->addButton(radio1,0);
    groupButton8->addButton(radio2,1);
    radio1->setChecked(true);

    connect(radio1,SIGNAL(clicked(bool)),this,SLOT(changefgv8()));
    connect(radio2,SIGNAL(clicked(bool)),this,SLOT(changefgv8()));

    //connect(radio1,SIGNAL(clicked(bool)),this,SLOT(slots_radioButton()));
    //connect(radio2,SIGNAL(clicked(bool)),this,SLOT(slots_radioButton()));



    /
    QLabel *ql9 = new QLabel(this);
    ql9->setText("frame_rate:");
    ql9->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
    ql9->setGeometry(25,240,100,30);

    //QComboBox *input9 = new QComboBox(this);
    input9 = new QComboBox(this);
    QStringList strList9;
    strList9<<"60"<<"30"<<"15"<<"7.5"<<"3.75"
           <<"1.875";
    input9->addItems(strList9);
    //input9->setCurrentIndex(-1);
    input9->setCurrentIndex(1);
    input9->setGeometry(125,240,100,30);

    connect(input9,SIGNAL(currentIndexChanged(int)),this,SLOT(changefgv9(double)));


    /
    QLabel *ql10 = new QLabel(this);
    ql10->setText("external trigger:");
    ql10->setWordWrap(true);
    ql10->adjustSize();
    ql10->setAlignment(Qt::AlignRight|Qt::AlignTop);
    ql10->setGeometry(425,240,100,50);



    QRadioButton *radio3 = new QRadioButton(tr("true"),this);
    QRadioButton *radio4 = new QRadioButton(tr("false"),this);
    radio3->setGeometry(530,240,100,30);
    radio4->setGeometry(625,240,100,30);

    QButtonGroup *groupButton10 = new QButtonGroup();
    groupButton10->addButton(radio3,0);
    groupButton10->addButton(radio4,1);
    radio4->setChecked(true);

    
    QLabel *ql11 = new QLabel(this);
    ql11->setText("disconnect graph:");
    ql11->setWordWrap(true);
    ql11->adjustSize();
    ql11->setAlignment(Qt::AlignRight|Qt::AlignTop);
    ql11->setGeometry(25,290,100,50);



    QRadioButton *radio5 = new QRadioButton(tr("true"),this);
    QRadioButton *radio6 = new QRadioButton(tr("false"),this);
    radio5->setGeometry(130,290,100,30);
    radio6->setGeometry(225,290,100,30);

    QButtonGroup *groupButton11 = new QButtonGroup();
    groupButton11->addButton(radio5,0);
    groupButton11->addButton(radio6,1);
    radio6->setChecked(true);

}

void Subwindow::changefgv1(int value)
{
    fg_value1 = value;
    qDebug()<<"fg_value1:"<checkedId())
    {
    case 0:
        qDebug()<<"on";
        fg_value8 = "on";
        break;
    case 1:
        qDebug()<<"off";
        fg_value8 = "off";
        break;
    }


    qDebug()<<"fg_value8:"<input9->currentData().toDouble();
    int curIndex = value;
    switch(curIndex)
    {
    case 0 :
        fg_value9 = 60;
        break;
    case 1 :
        fg_value9 = 30;
        break;
    case 2 :
        fg_value9 = 15;
        break;
    case 3 :
        fg_value9 = 7.5;
        break;
    case 4 :
        fg_value9 = 3.75;
        break;
    default :
        fg_value9 = 1.875;
        break;
    }

    qDebug()<<"index:"<

你可能感兴趣的:(Qt,Qt+Halcon,qt,c++)