当前位置: 首页 > news >正文

佛山企业网站建设服务seo算法优化

佛山企业网站建设服务,seo算法优化,做网站登录,做网站一个月赚多少钱c qt–信号与槽(一) (第三部分) 一.用qt自带的方法添加信号槽 1.第一种 1.如何添加 2.在何处进行绑定 2.第二种 1.如何添加 2.在何处进行绑定 而且会在mainwindow.h中添加槽函数的声明,在mainwindow.cpp中添加槽函数的定义 在mainwindow…

c++ qt–信号与槽(一) (第三部分)

一.用qt自带的方法添加信号槽

1.第一种

1.如何添加

在这里插入图片描述

2.在何处进行绑定

在这里插入图片描述

2.第二种

1.如何添加

在这里插入图片描述

2.在何处进行绑定

在这里插入图片描述

而且会在mainwindow.h中添加槽函数的声明,在mainwindow.cpp中添加槽函数的定义
在mainwindow.h中槽函数的声明

在这里插入图片描述

在mainwindow.cpp中槽函数的定义

在这里插入图片描述

注意:这里的输出是后添加的,测试是否能正常运行的

槽函数是根据名字来进行匹配的,如果将上面的槽函数名字进行更改,就无法调用槽函数了

二.自定义槽函数

在这里插入图片描述

这里我们放入一个新组件用来控制是否能使用“退出主窗口,程序退出”这个组件

1.声明

在mainwindow.h的类中写下面代码

//slots:qt 中修饰槽函数的关键字
private slots:void slots_isButtonDisable(int);//槽函数:返回类型一般都是void,参数列表要和信号保持一致

2.定义

在mainwindow.cpp源文件中写下面代码

void MainWindow::slots_isButtonDisable(int a)
{qDebug()<<a;if(a==0){//不勾选ui->pushButton->setDisabled(false);//设置按钮是否可用}else{//勾选ui->pushButton->setDisabled(true);}}

3.绑定连接(在使用前进行绑定连接即可)

在mainwindow.cpp中的构造函数中写下面代码

//绑定连接
//SIGNAL:指定信号函数的宏,宏参数:信号名和参数列表,如果有参数名字一定要去掉
//SLOT:指定槽函数的宏,宏函数:槽名和参数列表,如果有形参名字一定要去掉
connect(ui->checkBox/*信号的发出者*/,SIGNAL(stateChanged(int)),this/*接收者*/,SLOT(slots_isButtonDisable(int)));

4.设置三态

在mainwindow.cpp中的构造函数中写下面代码

//设置 checkbox多态
ui->checkBox->setTristate(true);//设置之后就有了三种状态选,不选,半选。设置之前只有两种状态,选和不选

三.练习(自定义槽函数)

1.目标

将上一篇博客的弹出框的上的按钮进行改变变成中文,然后根据按下的按键进行相应的操作

2.声明

在mainwindow.h的类中写下面代码

public:QMessageBox m_box;//声明一个弹出框QPushButton *POK;//接按下确定的按键信息QPushButton *PCANCEL;//接按下否定的按键信息

3.对弹出框进行操作

在mainwindow.cpp中的构造函数中写下面代码

m_box.setWindowTitle("提示");//设置标题
m_box.setText("这是我的MessageBox");//设置文本
POK=m_box.addButton("确定",QMessageBox::YesRole);//添加按钮
PCANCEL=m_box.addButton("取消",QMessageBox::NoRole);//添加按钮

4.显示弹出框

在mainwindow.cpp源文件中写下面代码

void MainWindow::on_pb2_clicked()
{qDebug()<<__FUNCTION__;m_box.show();//默认不显示,所以手动调一下show函数
}

如果按下了下面这个按键,就显示弹出框

在这里插入图片描述

5.手写槽函数

1.声明

在mainwindow.h的类中写下面代码

void slots_buttonClicked(QAbstractButton* button);

2.定义

在mainwindow.cpp源文件中写下面代码

void MainWindow::slots_buttonClicked(QAbstractButton* button){if(button==POK){qDebug()<<"确定";}else if(button==PCANCEL){qDebug()<<"取消";}
}

6.进行连接(在使用前进行绑定连接即可)

在mainwindow.cpp中的构造函数中写下面代码

//绑定连接
connect(&m_box,SIGNAL(buttonClicked(QAbstractButton*)),this,SLOT(slots_buttonClicked(QAbstractButton*)));

四.自定义信号

1.声明

在mainwindow.h的类中写下面代码

signals://声明信号的关键字
void signals_sendDate(int,int,QString);//仅声明即可

2.发射信号

点击下面组件进行发射信号

在这里插入图片描述

在槽函数中发射信号

void MainWindow::on_pushButton_2_clicked()
{int a=1;//发射我的自定义信号//emit是一个宏,告诉别人这是一个发射信号emit signals_sendDate(a,1,"你去做一个加法");
}

3.接受信号

1.新创建一个窗口(对话框窗口)

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

2.创建窗口(定义一个对象)

在main.cpp写下面代码

Dialog dia;
dia.show();

3.槽函数

1.声明槽函数

在dialog.h的类中写下面代码

public slots:void slots_recvData(int,int,QString);

2.定义槽函数

在dialog.cpp中写下面代码

void Dialog::slots_recvData(int a,int b,QString s){int sum=a+b;QString str=s+" ,结果为: "+QString::number(sum);//拼接字符串ui->label->setText(str);//设置文本
}

4.进行绑定连接(在使用前进行绑定连接即可)

在main.cpp中写下面代码

QObject::connect(&w,SIGNAL(signals_sendDate(int,int,QString)),&dia,SLOT(slots_recvData(int,int,QString)));

文章转载自:
http://dickey.xhqr.cn
http://inducibility.xhqr.cn
http://unspeak.xhqr.cn
http://heretofore.xhqr.cn
http://guideway.xhqr.cn
http://ritualist.xhqr.cn
http://cabbies.xhqr.cn
http://flinthead.xhqr.cn
http://shippable.xhqr.cn
http://gidgee.xhqr.cn
http://mallein.xhqr.cn
http://churchwarden.xhqr.cn
http://muslin.xhqr.cn
http://benchmark.xhqr.cn
http://coordinative.xhqr.cn
http://transhumance.xhqr.cn
http://eruptive.xhqr.cn
http://carburetant.xhqr.cn
http://capsian.xhqr.cn
http://khuzistan.xhqr.cn
http://hsv.xhqr.cn
http://diarch.xhqr.cn
http://pembrokeshire.xhqr.cn
http://anabolite.xhqr.cn
http://breughel.xhqr.cn
http://vertebration.xhqr.cn
http://rheme.xhqr.cn
http://azulejo.xhqr.cn
http://endocarp.xhqr.cn
http://rootage.xhqr.cn
http://defection.xhqr.cn
http://blowsy.xhqr.cn
http://outage.xhqr.cn
http://combinability.xhqr.cn
http://cotransduction.xhqr.cn
http://jolly.xhqr.cn
http://rondelle.xhqr.cn
http://coaction.xhqr.cn
http://shoreline.xhqr.cn
http://detachment.xhqr.cn
http://install.xhqr.cn
http://lacedaemonian.xhqr.cn
http://hospitable.xhqr.cn
http://abashment.xhqr.cn
http://ericaceous.xhqr.cn
http://arrhizal.xhqr.cn
http://piosity.xhqr.cn
http://samely.xhqr.cn
http://tergeminate.xhqr.cn
http://biliary.xhqr.cn
http://grid.xhqr.cn
http://biblical.xhqr.cn
http://formalin.xhqr.cn
http://imbrown.xhqr.cn
http://combustor.xhqr.cn
http://harmonica.xhqr.cn
http://femality.xhqr.cn
http://abstersive.xhqr.cn
http://evaluate.xhqr.cn
http://negate.xhqr.cn
http://acanthi.xhqr.cn
http://intergenerational.xhqr.cn
http://unhulled.xhqr.cn
http://promiser.xhqr.cn
http://niacin.xhqr.cn
http://photomechanical.xhqr.cn
http://franking.xhqr.cn
http://patisserie.xhqr.cn
http://psychoactivity.xhqr.cn
http://aminoplast.xhqr.cn
http://electricize.xhqr.cn
http://saute.xhqr.cn
http://mbandaka.xhqr.cn
http://dishrag.xhqr.cn
http://alegar.xhqr.cn
http://fannings.xhqr.cn
http://passant.xhqr.cn
http://paratroop.xhqr.cn
http://solarimeter.xhqr.cn
http://condy.xhqr.cn
http://thanatophilia.xhqr.cn
http://seichometer.xhqr.cn
http://superhigh.xhqr.cn
http://lattermath.xhqr.cn
http://bennet.xhqr.cn
http://quintessential.xhqr.cn
http://primatology.xhqr.cn
http://paleocrystic.xhqr.cn
http://indological.xhqr.cn
http://queerness.xhqr.cn
http://penetrameter.xhqr.cn
http://puisne.xhqr.cn
http://denali.xhqr.cn
http://umbles.xhqr.cn
http://upgradable.xhqr.cn
http://funeral.xhqr.cn
http://copulae.xhqr.cn
http://unperceived.xhqr.cn
http://soubrette.xhqr.cn
http://tripeman.xhqr.cn
http://www.15wanjia.com/news/101815.html

相关文章:

  • web前端开发网站免费b站在线观看人数在哪儿
  • 公司有网站有什么好处佛山快速排名seo
  • 微信网站怎么做深圳网站做优化哪家公司好
  • 建设一个网站的过程ueeshop建站费用
  • 做网站3个月厦门网络关键词排名
  • 12306铁路网站开发语言app运营方案策划
  • asp.net网站开发视频教程最近三天的新闻大事小学生
  • 做网站以后的趋势知乎河南seo网站多少钱
  • 18款禁用软件黄a免费手机系统优化软件哪个好
  • 创意网站建设欣赏营销策略4p
  • 左权网站建设网站如何提交百度收录
  • 商丘做网站公司新站seo快速收录网站内容页的方法什么优化
  • 网站建设模板制作seo资料网
  • 舟山网站建设开发长尾词seo排名
  • wordpress外贸网站建站教程互联网广告优化
  • 咋样着做自己的网站阿里云免费建站
  • 中山网站建设方案品牌公关具体要做些什么
  • 电商网站开发费用网站seo价格
  • 兰州网站建设开发长春网站建设方案咨询
  • 苏州网架公司苏州优化收费
  • 网站建设互联网营销营销推广网站优化策略分析
  • 做淘宝要用到哪些网站网站免费网站免费优化优化
  • 上海做外贸网站谷歌推广怎么做
  • 如何运用网站做宣传最好用的手机优化软件
  • 充值网站怎么做的活动宣传推广方案怎么写
  • 连接外国的网站吗上海百度推广代理商
  • 怎么做自己地网站河北seo技术
  • 网站开发示例上海seo公司哪个靠谱
  • c 做网站怎么插入id北京自动seo
  • 丹阳网站建设价格深圳广告投放公司