/****************************************************************************
** Meta object code from reading C++ file 'clicktest.h'
**
** Created by: The Qt Meta Object Compiler version 63 (Qt 4.8.5)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/
#include "../../clicktest.h"
#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'clicktest.h' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 63
#error "This file was generated using the moc from 4.8.5. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_clickTest[] = {
// content:
6, // revision
0, // classname
0, 0, // classinfo
1, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
0, // flags
0, // signalCount
// slots: signature, parameters, type, tag, flags
16, 11, 10, 10, 0x0a,
0 // eod
};
static const char qt_meta_stringdata_clickTest[] = {
"clickTest\0\0item\0switchClicked(QTableWidgetItem*)\0"
};
void clickTest::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
Q_ASSERT(staticMetaObject.cast(_o));
clickTest *_t = static_cast<clickTest *>(_o);
switch (_id) {
case 0: _t->switchClicked((*reinterpret_cast< QTableWidgetItem*(*)>(_a[1]))); break;
default: ;
}
}
}
const QMetaObjectExtraData clickTest::staticMetaObjectExtraData = {
0, qt_static_metacall
};
const QMetaObject clickTest::staticMetaObject = {
{ &QMainWindow::staticMetaObject, qt_meta_stringdata_clickTest,
qt_meta_data_clickTest, &staticMetaObjectExtraData }
};
#ifdef Q_NO_DATA_RELOCATION
const QMetaObject &clickTest::getStaticMetaObject() { return staticMetaObject; }
#endif //Q_NO_DATA_RELOCATION
const QMetaObject *clickTest::metaObject() const
{
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
}
void *clickTest::qt_metacast(const char *_clname)
{
if (!_clname) return 0;
if (!strcmp(_clname, qt_meta_stringdata_clickTest))
return static_cast<void*>(const_cast< clickTest*>(this));
return QMainWindow::qt_metacast(_clname);
}
int clickTest::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QMainWindow::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 1)
qt_static_metacall(this, _c, _id, _a);
_id -= 1;
}
return _id;
}
QT_END_MOC_NAMESPACE
QT使用tableWidget显示双排列表
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
![star](https://csdnimg.cn/release/downloadcmsfe/public/img/star.98a08eaa.png)
在QT编程中,`QTableWidget` 是一个非常常用的组件,用于展示表格数据。它可以用于创建用户界面,显示和编辑二维数据集。本教程将详细讲解如何使用`QTableWidget`来实现双排列表,并在选中时用红框突出显示。 我们需要了解`QTableWidget`的基本用法。`QTableWidget`继承自`QWidget`,提供了一个二维的格子布局,每个单元格可以包含文本、图像或其他复杂控件。我们可以通过设置列数和行数来初始化`QTableWidget`,并使用`setItem()`方法填充数据。 在创建双排列表时,我们可以设置`QTableWidget`的行数为2,然后在每一行中添加相应的列。例如,我们可以这样创建一个2x2的表格: ```cpp QTableWidget *table = new QTableWidget(); table->setRowCount(2); table->setColumnCount(2); ``` 接着,我们需要填充数据。每行的每个单元格都可以通过`setItem(row, column, item)`方法设置,其中`item`可以是` QTableWidgetItem`的实例。例如: ```cpp for (int i = 0; i < 2; ++i) { for (int j = 0; j < 2; ++j) { QTableWidgetItem *item = new QTableWidgetItem(QString("Row %1, Column %2").arg(i).arg(j)); table->setItem(i, j, item); } } ``` 为了实现选中时用红框圈出来,我们需要重写`QTableWidget`的样式表。`QTableWidget`的选中状态是通过其内部的`QTableWidgetItem`的背景色来体现的。我们可以通过以下方式设置选中项的样式: ```cpp table->setStyleSheet("QTableView::item:selected { background-color: red; border: 2px solid red; }"); ``` 这段代码设置了选中的表格项背景色为红色,并用红色边框包围。这将在用户选择某项时自动应用。 在实际项目中,你可能还需要监听选中事件,例如使用`currentChanged()`信号。当表格项的选中状态改变时,这个信号会被发射。你可以连接这个信号到一个槽函数,以便在用户选择新的项时执行某些操作: ```cpp connect(table, &QTableWidget::currentCellChanged, this, &YourClass::onCurrentCellChanged); ``` 在`onCurrentCellChanged`槽函数中,你可以获取当前选中的行和列,并进行进一步的处理。 别忘了将`QTableWidget`添加到你的布局中,以便它能在界面上正确显示: ```cpp QVBoxLayout *layout = new QVBoxLayout(); layout->addWidget(table); setLayout(layout); ``` 以上就是使用QT的`QTableWidget`创建双排列表,并在选中时用红框突出显示的完整步骤。通过理解`QTableWidget`的基本用法和定制样式,你可以轻松地创建出满足需求的表格界面。在实际开发中,你可能还需要处理更多细节,如数据的动态加载、编辑功能以及更多的自定义样式,但这些都基于上述基础。
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![7z](https://img-home.csdnimg.cn/images/20241231044736.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/EXE.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
- 1
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
- #完美解决问题
- #运行顺畅
- #内容详尽
- #全网独家
- #注释完整
- jingwang-cs2014-08-14我用的Qt5,导入不进去,也运行不起来呀。
![avatar](https://profile-avatar.csdnimg.cn/3781efffed1e41a789ab280fd290f6cd_itas109.jpg!1)
- 粉丝: 1w+
- 资源: 64
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
- 基于Java语言的演唱会订票系统设计源码
- (源码)基于HTTP技术的学习笔记项目.zip
- 基于Java与Vue的游客服务系统设计源码
- (源码)基于C++语言的井字棋游戏.zip
- 基于TypeScript的英语单词记忆软件设计源码
- 基于支付宝小程序的打卡气候行动设计源码
- 基于PHP和前端语言的APP会员基础应用设计源码
- (源码)基于Arduino的实时时钟系统.zip
- (源码)基于STM32G431RB的简易电子琴项目.zip
- 基于Java开发的公寓租赁平台移动端及后台管理系统设计源码
- 基于Vue.js的鲸豚科普与社群互动平台设计源码
- (源码)基于C++的红色警戒在线RTS游戏.zip
- 基于Python核心技术的新闻信息网站全栈设计源码
- 基于Java语言的guli学院后端设计源码
- 基于JavaScript和PHP的广东省特色沙发设计源码分享
- (源码)基于C++和EPOLL的单线程并发Http服务器.zip
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)