QT 控件和ID绑定 QObjectUserData
来源:互联网 发布:槟榔淘宝店铺怎么装修 编辑:程序博客网 时间:2024/05/16 11:17
#define CDATABIND_H
#include <QObjectUserData>
class CDatabind : public QObjectUserData
{
public:
CDatabind();
void SetUserData(int ROw, int col);
public:
int m_nRow;
int m_nCol;
};
#endif // CDATABIND_H
#include "cdatabind.h"
CDatabind::CDatabind()
{
m_nRow = -1;
m_nCol = -1;
}
void CDatabind::SetUserData(int row, int col)
{
m_nRow = row;
m_nCol = col;
}
使用
QPushButton *open = new QPushButton("打开");
CDatabind *bindopen = new CDatabind();
bindopen->SetUserData(i, 4);
open->setUserData(0, bindopen);
ui->tableWidget->setCellWidget(i, 4, open);
connect(open, SIGNAL(clicked()), this, SLOT(OnBtnOpendoor()));
QPushButton *lock = new QPushButton("锁定");
CDatabind *bindlock = new CDatabind();
bindlock->SetUserData(i, 5);
lock->setUserData(0, bindlock);
ui->tableWidget->setCellWidget(i, 5, lock);
connect(lock, SIGNAL(clicked()), this, SLOT(OnBtnLockdoor()));
void CDoorctl::OnBtnOpendoor()
{
QPushButton *btn = (QPushButton *)sender();
CDatabind *open = (CDatabind *)btn->userData(0);
int row = open->m_nRow;
int col = open->m_nCol;
int m=0;
}
void CDoorctl::OnBtnLockdoor()
{
QPushButton *btn = (QPushButton *)sender();
CDatabind *open = (CDatabind *)btn->userData(0);
int row = open->m_nRow;
int col = open->m_nCol;
int m=0;
}
- QT 控件和ID绑定 QObjectUserData
- 【QT】:QT如何实现LineEdit控件和textlabel控件的绑定
- 用反射和注解,绑定控件的id和点击事件
- MFC 自定义控件 ID与信息绑定
- Butterknife @OnClick绑定多控件id
- Butterknife bindview @OnClick绑定多控件id
- 数据绑定控件中查找指定ID的控件
- android 控件ID时@id/XX和@+id/xx 区别
- qt绑定回车键和确定按钮
- 服务器端控件三种ID:ID,ClientID和UniqueID
- 服务器端控件三种ID:ID,ClientID和UniqueID
- 服务器端控件三种ID:ID,ClientID和UniqueID
- 服务器端控件三种ID:ID,ClientID和UniqueID
- masterpage中FORM和控件ID
- 修改服务器控件的ID和Name
- 控件Name和id的区别
- 分不清控件的服务端和客户端ID
- Eval数据绑定语法绑定Image、Label和HyperLink控件
- Android AccessibilityService 使用详解
- java中判断字符串是否为数字的方法的几种方法
- UIPageController的使用
- React富交互性的动态用户界面
- OO实现ALV
- QT 控件和ID绑定 QObjectUserData
- iOS开发之 线程安全机制
- 排序算法总结
- Spring策略模式
- 小白对于unity一些机制的探索(一)
- C#读取excel并保存到Oracle数据库
- 修饰符的概述和总结
- Android入门:封装一个HTTP请求的辅助类
- spring中配置log4j