机器人膀子能动,其他部位自己可以去加

#ifndef WIDGET_H
#define WIDGET_H#include <QWidget>
#include <QPushButton>
#include <QLabel>class Widget : public QWidget
{Q_OBJECTpublic:Widget(QWidget *parent = nullptr);~Widget();protected slots:void on_CombinationClicked();void on_LeftClicked();void on_UpClicked();private:QPushButton *m_pHeadBtn=nullptr;QPushButton *m_pNeckBtn=nullptr;QPushButton *m_pBodyBtn=nullptr;QPushButton *m_pLeftLegBtn=nullptr;QPushButton *m_pRightLegBtn=nullptr;QPushButton *m_pRightHandBtn=nullptr;QPushButton *m_pLeftHandBtn=nullptr;QPushButton *m_pCombinationBtn=nullptr;QPushButton *m_pLeftBtn=nullptr;QPushButton *m_pUpBtn=nullptr;
};
#endif // WIDGET_H

.cpp

#include "widget.h"
#include <QGridLayout>
#include <QKeyEvent>
#include <QPropertyAnimation>Widget::Widget(QWidget *parent): QWidget(parent)
{m_pCombinationBtn=new QPushButton(tr("Combination"),this);m_pCombinationBtn->setFixedSize(100,25);m_pLeftBtn=new QPushButton(tr("Left"),this);m_pLeftBtn->setFixedSize(100,25);m_pLeftBtn->move(100,0);m_pUpBtn=new QPushButton(tr("Up"),this);m_pUpBtn->setFixedSize(100,25);m_pUpBtn->move(200,0);m_pHeadBtn=new QPushButton(tr("0.0"),this);m_pNeckBtn=new QPushButton(tr(""),this);m_pBodyBtn=new QPushButton(tr(""),this);m_pLeftLegBtn=new QPushButton(tr(""),this);m_pRightLegBtn=new QPushButton(tr(""),this);m_pRightHandBtn=new QPushButton(tr(""),this);m_pLeftHandBtn=new QPushButton(tr(""),this);m_pHeadBtn->setFixedSize(100,50);m_pNeckBtn->setFixedSize(30,40);m_pBodyBtn->setFixedSize(150,200);m_pLeftLegBtn->setFixedSize(30,100);m_pRightLegBtn->setFixedSize(30,100);m_pRightHandBtn->setFixedSize(100,30);m_pLeftHandBtn->setFixedSize(100,30);m_pRightHandBtn->setStyleSheet("background:green");m_pLeftHandBtn->setStyleSheet("background:green");QFont font;font.setPointSize(15);font.setBold(true);m_pHeadBtn->setFont(font);m_pHeadBtn->move(0,30);m_pNeckBtn->move(110,30);m_pBodyBtn->move(140,30);m_pLeftLegBtn->move(290,30);m_pRightLegBtn->move(330,30);m_pRightHandBtn->move(370,30);m_pLeftHandBtn->move(480,30);connect(m_pCombinationBtn,&QPushButton::clicked,this,&Widget::on_CombinationClicked);connect(m_pLeftBtn,&QPushButton::clicked,this,&Widget::on_LeftClicked);connect(m_pUpBtn,&QPushButton::clicked,this,&Widget::on_UpClicked);}Widget::~Widget()
{}void Widget::on_CombinationClicked()
{QPropertyAnimation *animation = new QPropertyAnimation(m_pHeadBtn, "geometry");animation->setDuration(2000);animation->setStartValue(QRect(0, 30, 100, 50));animation->setEndValue(QRect(200, 30, 100, 50));animation->start();QPropertyAnimation *animation1 = new QPropertyAnimation(m_pNeckBtn, "geometry");animation1->setDuration(2000);animation1->setStartValue(QRect(110, 30, 30, 40));animation1->setEndValue(QRect(240, 80, 30, 40));animation1->start();QPropertyAnimation *animation2 = new QPropertyAnimation(m_pBodyBtn, "geometry");animation2->setDuration(2000);animation2->setStartValue(QRect(140, 30, 150, 200));animation2->setEndValue(QRect(180, 120, 150, 200));animation2->start();QPropertyAnimation *animation3 = new QPropertyAnimation(m_pLeftLegBtn, "geometry");animation3->setDuration(2000);animation3->setStartValue(QRect(290, 30, 30, 100));animation3->setEndValue(QRect(200, 320, 30, 100));animation3->start();QPropertyAnimation *animation4 = new QPropertyAnimation(m_pRightLegBtn, "geometry");animation4->setDuration(2000);animation4->setStartValue(QRect(330, 30, 30, 100));animation4->setEndValue(QRect(280, 320, 30, 100));animation4->start();QPropertyAnimation *animation5 = new QPropertyAnimation(m_pRightHandBtn, "geometry");animation5->setDuration(2000);animation5->setStartValue(QRect(370, 30, 100, 30));animation5->setEndValue(QRect(330, 140, 100, 30));animation5->start();QPropertyAnimation *animation6 = new QPropertyAnimation(m_pLeftHandBtn, "geometry");animation6->setDuration(2000);animation6->setStartValue(QRect(480, 30, 100, 30));animation6->setEndValue(QRect(180, 140, 100, 30));animation6->start();}void Widget::on_LeftClicked()
{QPoint pos=m_pRightHandBtn->pos();int width=m_pRightHandBtn->width();int height=m_pRightHandBtn->height();m_pRightHandBtn->setFixedSize(100,30);QPropertyAnimation *animation5 = new QPropertyAnimation(m_pRightHandBtn, "geometry");animation5->setDuration(2000);animation5->setStartValue(QRect(pos.x(), pos.y(), width, height));animation5->setEndValue(QRect(230, 140, 100, 30));animation5->start();QPoint pos1=m_pLeftHandBtn->pos();int width1=m_pLeftHandBtn->width();int height1=m_pLeftHandBtn->height();m_pLeftHandBtn->setFixedSize(100,30);QPropertyAnimation *animation6 = new QPropertyAnimation(m_pLeftHandBtn, "geometry");animation6->setDuration(2000);animation6->setStartValue(QRect(pos1.x(), pos1.y(), width1, height1));animation6->setEndValue(QRect(80, 140, 100, 30));animation6->start();
}void Widget::on_UpClicked()
{QPoint pos=m_pRightHandBtn->pos();int width=m_pRightHandBtn->width();int height=m_pRightHandBtn->height();m_pRightHandBtn->setFixedSize(30,100);QPropertyAnimation *animation5 = new QPropertyAnimation(m_pRightHandBtn, "geometry");animation5->setDuration(2000);animation5->setStartValue(QRect(pos.x(), pos.y(), width, height));animation5->setEndValue(QRect(330, 70, 30, 100));animation5->start();int width1=m_pLeftHandBtn->width();int height1=m_pLeftHandBtn->height();QPoint pos1=m_pLeftHandBtn->pos();m_pLeftHandBtn->setFixedSize(30,100);QPropertyAnimation *animation6 = new QPropertyAnimation(m_pLeftHandBtn, "geometry");animation6->setDuration(2000);animation6->setStartValue(QRect(pos1.x(), pos1.y(), width1, height1));animation6->setEndValue(QRect(150, 70, 30, 100));animation6->start();
}

闲来无事写个qt实现机器人相关推荐

  1. 写一个 panic blame 机器人

    最近接手了一个"公共"服务,负责维护它的稳定性.代码库有很多人参与"维护",其实就是各种业务方使劲往上堆逻辑.虽然入库前我会进行 CR,但多了之后,也看不过来, ...

  2. 用android写的微信闲聊机器人

    这两天看网上有人写了个微信机器人,感觉挺有趣的,查了下网上资料的思路,大都都是用的网页版微信. 我用了一个小号微信去登陆网页版,发现既然登不了,必须使用我的老号才能登陆,网上还有人说以后腾讯要关掉网页 ...

  3. Qt设计机器人仿真控制器——按键控制机器人关节转动

    1.引言及本文简介 在上两篇博客里,Jungle介绍了Qt键盘事件,并在小程序中应用Qt键盘事件监测按键输入: Qt键盘事件(一)--检测按键输入及解决无法响应方向键问题 Qt键盘事件(二)--长按按 ...

  4. 手把手教你写一个中文聊天机器人

    本文来自作者 赵英俊(Enjoy) 在 GitChat 上分享 「手把手教你写一个中文聊天机器人」,「阅读原文」查看交流实录. 「文末高能」 编辑 | 哈比 一.前言 发布这篇 Chat 的初衷是想和 ...

  5. 【C 语言】文件操作 ( 写文本文件 | Qt 创建 C 语言命令行项目 )

    文章目录 一.创建 Qt 纯 C 语言项目 二.文件写文本操作 三.命令行输入字符串并保存 一.创建 Qt 纯 C 语言项目 打开 Qt 工具 , 选择 " 菜单栏 / 文件 / 新建文件或 ...

  6. 16岁成为全栈开发者:我从开发游戏到写加密货币投资机器人的心路历程

    选自Medium 作者:Nuno Martins 机器之心编译 参与:Luo Sainan.一鸣 全栈开发者听起来是个很高大上的程序员岗位,似乎没有几年工作经验是 Hold 不住的.但是,有个葡萄牙少 ...

  7. python写机器人程序_用Python写的一个多线程机器人聊天程序

    本人是从事php开发的, 近来想通过php实现即时通讯(兼容windows).后来发现实现起来特别麻烦, 就想到python.听说这家伙在什么地方都能发挥作用.所以想用python来做通讯模块...所 ...

  8. 从 Forces 开始分析责任链模式:「写一个 Discord 对话机器人」

    目录 前言 你收到了一份需求 面向对象分析 (OOA) 初版程式实作 察觉 Forces 套用责任链模式 (OOD) 封装变动之处 (Encapsulate what varies) 萃取共同行为 ( ...

  9. 写一个福利 Telegram 机器人

    官网 创建 bot 根据文档,在 telegram 里面添加 @BotFather, 然后跟他聊天来创建机器人 拿到 token 测试 在浏览器中(翻墙)输入 https://api.telegram ...

  10. 利用qt实现机器人可视化界面,并在界面上控制机器人各个关节运动

    本工程借助于clion配置的qt环境,同时依赖eigen tinyxml2等开源库,也借鉴了博客上一些文章,具体哪些忘记了,十分抱歉.本工程仅供参考.机械臂模型为史陶比尔官网的TX2-60L-HB.可 ...

最新文章

  1. Java Web整合开发(10) -- 资源国际化
  2. ExcelReport第三篇:扩展元素格式化器
  3. 120所国家重点建设大学(211工程和教育部直属)[国家一类本科大学]详细情况一览表...
  4. Win7 安装资料及教程
  5. 电网操作:线路、主变、母线操作讲解
  6. 纯css制作带三角(兼容所有浏览器)
  7. windows 虚拟地址映射到物理地址
  8. 拿下京东榜单第五首战告捷,看联想手机如何上演王者归来
  9. 设计师Yoyo:为用户设计产品,让他们生活更美好
  10. amazon linux ami root 密码,Ubuntu Server的Amazon AMI映像的默认用户名是什么?
  11. 打破多项存储世界记录,宏杉科技表示很淡定
  12. 计算机大学生职业规划书word模板,大学生职业生涯规划书模板(附word)
  13. 工业相机选型和镜头焦距计算
  14. 经验10年搞不过卖烧烤的!后入阿里我软件测试是怎么学废的,这些话我想送给一事无成的自学测试们...
  15. 英伟达最新驱动打开3d vision功能
  16. 鸿蒙初开再往前是什么,鸿蒙初开造句,用鸿蒙写一句话
  17. 树的序列化——浅谈 dfn 与欧拉序列
  18. android 装苹果系统,安卓机子安装苹果IOS系统?
  19. Visual Studio 2019背景美化(背景透明化+自定义背景图片)
  20. java中有几种方法可以实现一个线程?用什么关键字修饰同步方法? stop()和suspend()方法为何不推荐使用?

热门文章

  1. MongoDB学习(黑马教程)-4-数据库MongoDB的更新(修改)文档操作
  2. php查询mysql表里的数据_PHP连接Mysql数据库读取表格数据
  3. java访问带有密码验证的es_elasticsearch x_pack带验证 java配置访问
  4. sqlalchemy mysql配置中怎么设置utf8_python – 使用SQLAlchemy和pymysql,如何设置连接以使用utf8mb4?...
  5. pe修改rpc服务器不可用,电脑rpc服务器不可用,教你电脑rpc服务器不可用怎么解决...
  6. 计算机网络基础学ppt,计算机网络基础学习情景.ppt
  7. dart参数传方法_Dart是值传递还是引用传递?
  8. infoq mysql索引_MySQL 索引优化指南
  9. CMU 15-213 Introduction to Computer Systems学习笔记(22) Synchronization: Advanced
  10. ## 在webapp上使用input:file, 指定capture属性调用默认相机,摄像,录音功能