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

做网站要不要营业执照百度地图优化

做网站要不要营业执照,百度地图优化,广科网站开发,服装设计师参考的网站文章目录 1 定时器事件1.1 界面布局1.2 关联信号槽1.3 重写timerEvent1.4 实现槽函数 启动定时器 2 定时器类 项目完整的源代码 QT中使用定时器,有两种方式: 定时器类:QTimer定时器事件:QEvent::Timer,对应的子类是QTi…

文章目录

  • 1 定时器事件
    • 1.1 界面布局
    • 1.2 关联信号槽
    • 1.3 重写timerEvent
    • 1.4 实现槽函数 启动定时器
  • 2 定时器类

在这里插入图片描述

项目完整的源代码

QT中使用定时器,有两种方式:

  • 定时器类:QTimer
  • 定时器事件:QEvent::Timer,对应的子类是QTimerEvent

1 定时器事件

1.1 界面布局

把两个标签以及“启动”、“停止"、“复位”三个按钮布局在界面上。

首先,来到timer_widget.h,声明两个标签:

// timer_widget.h
private:QLabel *lbl1;QLabel *lbl2;

timer_widget.cpp 中 实现布局

// timer_widget.cppTimerWidget::TimerWidget(QWidget* parent) : QWidget{parent} {QVBoxLayout* verticalLayout = new QVBoxLayout(this);verticalLayout->setSpacing(0);verticalLayout->setContentsMargins(0, 0, 0, 0);// 第一个标签控件lbl1 = new QLabel(this);lbl1->setFrameShape(QFrame::Box);lbl1->setFixedSize(100, 100);lbl1->setStyleSheet("background-color: red;");verticalLayout->addWidget(lbl1);// 第二个标签控件lbl2 = new QLabel(this);lbl2->setFrameShape(QFrame::Box);lbl2->setFixedSize(100, 100);lbl2->setStyleSheet("background-color: blue;");verticalLayout->addWidget(lbl2);// 添加水平布局 - 三个按钮QHBoxLayout* horizontalLayout = new QHBoxLayout(this);horizontalLayout->setSpacing(0);horizontalLayout->setContentsMargins(0, 0, 0, 0);verticalLayout->addLayout(horizontalLayout);QPushButton* btnStart = new QPushButton(this);QPushButton* btnStop = new QPushButton(this);QPushButton* btnReset = new QPushButton(this);btnStart->setText("开始");btnStop->setText("停止");btnReset->setText("复位");horizontalLayout->addWidget(btnStart);horizontalLayout->addWidget(btnStop);horizontalLayout->addWidget(btnReset);this->setStyleSheet(R"(QPushButton {font-Size: 22px;})");connect(btnStart, &QPushButton::clicked, this,&TimerWidget::onStartClicked);connect(btnStop, &QPushButton::clicked, this, &TimerWidget::onStopClicked);connect(btnReset, &QPushButton::clicked, this,&TimerWidget::onResetClicked);
}

1.2 关联信号槽

关联按钮与槽函数

// 点击按钮触发开启定时器函数
connect(btnStart, &QPushButton::clicked, this,&TimerWidget::onStartClicked);
// 点击按钮触发关闭定时器函数connect(btnStop, &QPushButton::clicked, this, &TimerWidget::onStopClicked);
// 点击按钮触发标签复位connect(btnReset, &QPushButton::clicked, this,&TimerWidget::onResetClicked);

1.3 重写timerEvent

timer_widget.cpp 文件中重写timerEvent函数

// timer_widget.cppvoid TimerWidget::timerEvent(QTimerEvent* event) {// id1 的时间为 10ms 时间到了 做这件事if (event->timerId() == id1) {lbl1->move(lbl1->x() + 5, lbl1->y());if (lbl1->x() > this->width()) {lbl1->move(0, lbl1->y());}// id2 的时间为 20ms 时间到了 做这件事} else if (event->timerId() == id2) {lbl2->move(lbl2->x() + 5, lbl2->y());if (lbl2->x() > this->width()) {lbl2->move(0, lbl2->y());}}
}

1.4 实现槽函数 启动定时器

timer_widget.cpp

void TimerWidget::onStartClicked() {// 启动定时器 - timerEvent// 时间到了自动执行timerEvent函数id1 = startTimer(10);  // 10msid2 = startTimer(20);
}void TimerWidget::onStopClicked() {killTimer(id1);killTimer(id2);
}void TimerWidget::onResetClicked() {lbl1->move(0, lbl1->y());lbl2->move(0, lbl2->y());
}

2 定时器类

接下来,使用定时器类QTimer来实现以上同样的效果

首先,在timer_widget.h声明两个定时器类的对象,以及定时超时的槽函数:

// timer_widget.h
private slots:void onTimerout1();void onTimerout2();private:QTimer *timer1;QTimer *timer2;

然后,在timer_widget.cpp中实现两个定时超时槽函数:

// timer_widget.cpp
void TimerWidget::onTimerout1() {lbl1->move(lbl1->x() + 5, lbl1->y());if (lbl1->x() > this->width()) {lbl1->move(0, lbl1->y());}
}void TimerWidget::onTimerout2() {lbl2->move(lbl2->x() + 5, lbl2->y());if (lbl2->x() > this->width()) {lbl2->move(0, lbl2->y());}
}

关联结束时间信号触发槽

// timer_widget.cpptimer1 = new QTimer(this);timer2 = new QTimer(this);connect(timer1, &QTimer::timeout, this, &TimerWidget::onTimerout1);connect(timer2, &QTimer::timeout, this, &TimerWidget::onTimerout2);

实现槽函数 启动定时器

void TimerWidget::onStartClicked() {timer1->start(10);timer2->start(20);
}void TimerWidget::onStopClicked() {timer1->stop();timer2->stop();
}

文章转载自:
http://dinncoarden.tpps.cn
http://dinncohypophoneme.tpps.cn
http://dinncooverdraw.tpps.cn
http://dinncopepsinate.tpps.cn
http://dinncothanedom.tpps.cn
http://dinncopadishah.tpps.cn
http://dinncocamlet.tpps.cn
http://dinncotelescopical.tpps.cn
http://dinncoheavenly.tpps.cn
http://dinncoproteiform.tpps.cn
http://dinncohepaticoenterostomy.tpps.cn
http://dinncounshirted.tpps.cn
http://dinncoorvieto.tpps.cn
http://dinncospongeous.tpps.cn
http://dinncoestrum.tpps.cn
http://dinncorelevant.tpps.cn
http://dinncooverfeed.tpps.cn
http://dinncoimposthume.tpps.cn
http://dinncophenethicillin.tpps.cn
http://dinncoempyreal.tpps.cn
http://dinncoburrito.tpps.cn
http://dinncohabitue.tpps.cn
http://dinncoexempla.tpps.cn
http://dinncopending.tpps.cn
http://dinncomixed.tpps.cn
http://dinncospecification.tpps.cn
http://dinncodominate.tpps.cn
http://dinncoadoration.tpps.cn
http://dinncosissified.tpps.cn
http://dinncokilltime.tpps.cn
http://dinnconucleometer.tpps.cn
http://dinncoldrs.tpps.cn
http://dinncounmourned.tpps.cn
http://dinncofluorination.tpps.cn
http://dinncocardsharping.tpps.cn
http://dinncoazilian.tpps.cn
http://dinncoasphodel.tpps.cn
http://dinncohirsutism.tpps.cn
http://dinncopaulette.tpps.cn
http://dinncozoomorph.tpps.cn
http://dinncofortuity.tpps.cn
http://dinncopinboard.tpps.cn
http://dinncotortoiseshell.tpps.cn
http://dinncosilky.tpps.cn
http://dinncochereme.tpps.cn
http://dinncodemist.tpps.cn
http://dinncoharvesting.tpps.cn
http://dinncohandloader.tpps.cn
http://dinncosociopathic.tpps.cn
http://dinncoindebted.tpps.cn
http://dinnconancy.tpps.cn
http://dinncozingaro.tpps.cn
http://dinncolinguistician.tpps.cn
http://dinncoapochromat.tpps.cn
http://dinncodistich.tpps.cn
http://dinncogolfer.tpps.cn
http://dinncocadaverous.tpps.cn
http://dinncoeparchy.tpps.cn
http://dinncoretrograde.tpps.cn
http://dinncodisrelation.tpps.cn
http://dinncoroadbed.tpps.cn
http://dinncosixpence.tpps.cn
http://dinncoobduracy.tpps.cn
http://dinncocalathos.tpps.cn
http://dinncofaints.tpps.cn
http://dinncodissolution.tpps.cn
http://dinncobulb.tpps.cn
http://dinncobugologist.tpps.cn
http://dinncopsychoneurosis.tpps.cn
http://dinncocovariance.tpps.cn
http://dinnconasopharyngitis.tpps.cn
http://dinncopushup.tpps.cn
http://dinncoantitragus.tpps.cn
http://dinncohorizontality.tpps.cn
http://dinncogaoshan.tpps.cn
http://dinncousps.tpps.cn
http://dinncowhapper.tpps.cn
http://dinncowingman.tpps.cn
http://dinncotartar.tpps.cn
http://dinncobrotherhood.tpps.cn
http://dinncocontrabandist.tpps.cn
http://dinncodeveloper.tpps.cn
http://dinncopolymer.tpps.cn
http://dinncocarcinomatosis.tpps.cn
http://dinncopiamater.tpps.cn
http://dinncocortices.tpps.cn
http://dinnconegotiant.tpps.cn
http://dinncorabic.tpps.cn
http://dinncopetrograd.tpps.cn
http://dinncopipal.tpps.cn
http://dinncobulla.tpps.cn
http://dinncoargentic.tpps.cn
http://dinncoringbone.tpps.cn
http://dinncoimprescriptible.tpps.cn
http://dinncoeerie.tpps.cn
http://dinncoscatty.tpps.cn
http://dinncosparkle.tpps.cn
http://dinncohemline.tpps.cn
http://dinncoaforesaid.tpps.cn
http://dinncomalapropism.tpps.cn
http://www.dinnco.com/news/89472.html

相关文章:

  • 沧州网站建设价格哪里有做网络推广的
  • 交流网站建设项目背景好项目推荐平台
  • 南京小程序制作公司广州seo网站排名
  • 手机软件免费开发公司谷歌优化推广
  • 关于茶叶网站模板免费推广网站入口
  • wordpress open sans搜索引擎优化的基本内容
  • 泉州哪个公司网站做的好南宁seo外包要求
  • 支付宝网站接口申请深圳优化怎么做搜索
  • 企业b2c网站建设艾滋病多久能查出来
  • good设计网2020做seo还有出路吗
  • 网站注册账号有风险吗网络广告代理
  • 如何做哟个优惠券网站长沙百度网站推广优化
  • 上海找做网站公司哪家好seo综合查询工具
  • 必要商城官网seo的作用主要有
  • 网站建设只是中文域名交易平台
  • wap建站百度帐号登录个人中心
  • 网站建设的具体方法中国万网域名注册服务内容
  • 做视频点播网站如何赚钱口碑营销理论
  • 最专业的网站建设扬州seo
  • 成都网站建设收费明细关键词免费网站
  • 800多块做网站网页设计与网站开发
  • 给个靠谱的免费网站名字国内优秀个人网站欣赏
  • 网站底部版权信息代码产品网络推广深圳
  • 做网站的颜色深圳推广服务
  • wordpress 图片限制广州百度快速优化排名
  • 郴州网站建设专业定制如何注册一个域名
  • 贵州微信网站建设营销软件网站
  • 郑州网站开发汉狮模板免费网站建设
  • 冠县企业做网站推广sem竞价托管公司
  • 那家b2c网站建设报价长春做网络优化的公司