6 Star 11 Fork 7

zhyuey/PokerGame

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
pokerscene.cpp 1.38 KB
一键复制 编辑 原始数据 按行查看 历史
#include "pokerscene.h"
#include "pokercarditem.h"
#include <QGraphicsItem>
#include <QDebug>
#include <Qt>
PokerScene::PokerScene(QObject *parent) :
QGraphicsScene(parent)
{
}
void PokerScene::mousePressEvent(QGraphicsSceneMouseEvent * mouseEvent)
{
if(mouseEvent->button() == Qt::LeftButton)
{
QGraphicsItem *item = this->itemAt(mouseEvent->scenePos(), QTransform());
if(!item) return;
if(item->type() == QGraphicsItem::UserType + 1 )
{
PokerCardItem *svgitem;
svgitem = qgraphicsitem_cast<PokerCardItem *>(item);
if(svgitem->clickable() == true)
{
QPointF pos = svgitem->pos();
if(svgitem->isClicked())
{
svgitem->setPos(pos.x(), pos.y() + 20);
svgitem->setClicked(false);
}
else
{
svgitem->setPos(pos.x(), pos.y() - 20);
svgitem->setClicked(true);
}
}
}
if(item->type() == QGraphicsSvgItem::Type)
{
if(item->data(0).toString() == "Play")
emit playCards();
if(item->data(0).toString() == "Pass")
emit passRound();
}
}
else if (mouseEvent->button() == Qt::RightButton)
{
emit playCards();
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/zhyuey/PokerGame.git
git@gitee.com:zhyuey/PokerGame.git
zhyuey
PokerGame
PokerGame
master

搜索帮助