- 浏览: 718846 次
- 性别:
- 来自: 深圳
文章分类
- 全部博客 (1042)
- 数据结构 (36)
- UML与设计模式 (42)
- c++ (87)
- rust (36)
- Qt (41)
- boost模板元编程 (43)
- Linux (77)
- 汇编 (4)
- 其它 (2)
- 烹饪 (3)
- unix c / socket (73)
- 软件工程 (4)
- shell (52)
- Python (37)
- c++ primer 5th(c++11) (22)
- 数据库/MySQL (27)
- 数据存储 (4)
- lisp (7)
- git (4)
- Utility (3)
- CDN与DNS (54)
- Http (53)
- php (7)
- nginx/lua/openresty (41)
- redis (11)
- TCP/IP (16)
- 互联网 (6)
- kernel (2)
- go (33)
- 区块链 (43)
- 比特股 (13)
- 以太坊 (23)
- 比特币 (23)
- 密码学 (10)
- EOS (53)
- DAG (1)
- docker (1)
- filecoin (7)
- solidity (64)
- ipfs (8)
- 零知识证明 (1)
- openzeppelin (3)
- java (1)
- defi (7)
最新评论
原文http://www.cppblog.com/biao/archive/2009/08/07/92577.html
狂奔的蜗牛很给力
1. 设置QTableView启用鼠标跟踪:
ui->tableView->setMouseTracking(true);
2. 与QTableView的entered信号连接:
connect(ui->tableView, SIGNAL(entered(QModelIndex)),
this, SLOT(showToolTip(QModelIndex)));
3. 糟函数:
void Widget::showToolTip(const QModelIndex &index) {
if (!index.isValid()) {
qDebug() << "Invalid index";
return;
}
QToolTip::showText(QCursor::pos(), index.data().toString() + "\ngoto hell");
}
QCursor::pos(): 返回鼠标的位置.
4. 使用QTableView自己带的函数,函数原型如下:
ui.tableWidget->resizeColumnToContents (0);
将第一列根据内容自动调整列宽。
根据内容自动调整某列的列宽
void QTableView::resizeColumnToContents ( int column ) [slot]
Resizes the given column based on the size hints of the delegate used to render each item in the column.
根据内容自动调整所有列的列宽
void QTableView::resizeColumnsToContents () [slot]
Resizes all columns based on the size hints of the delegate used to render each item in the columns.
根据内容自动调整某一行的行高
void QTableView::resizeRowToContents ( int row ) [slot]
Resizes the given row based on the size hints of the delegate used to render each item in the row.
根据内容自动调整所有行的行高。
void QTableView::resizeRowsToContents () [slot]
Resizes all rows based on the size hints of the delegate used to render each item in the rows.
设置日志:我用了下,感觉没有打时间啊,而且比较粗糙。。。回头有时间自己加点代码完善下
狂奔的蜗牛很给力
1. 设置QTableView启用鼠标跟踪:
ui->tableView->setMouseTracking(true);
2. 与QTableView的entered信号连接:
connect(ui->tableView, SIGNAL(entered(QModelIndex)),
this, SLOT(showToolTip(QModelIndex)));
3. 糟函数:
void Widget::showToolTip(const QModelIndex &index) {
if (!index.isValid()) {
qDebug() << "Invalid index";
return;
}
QToolTip::showText(QCursor::pos(), index.data().toString() + "\ngoto hell");
}
QCursor::pos(): 返回鼠标的位置.
4. 使用QTableView自己带的函数,函数原型如下:
ui.tableWidget->resizeColumnToContents (0);
将第一列根据内容自动调整列宽。
根据内容自动调整某列的列宽
void QTableView::resizeColumnToContents ( int column ) [slot]
Resizes the given column based on the size hints of the delegate used to render each item in the column.
根据内容自动调整所有列的列宽
void QTableView::resizeColumnsToContents () [slot]
Resizes all columns based on the size hints of the delegate used to render each item in the columns.
根据内容自动调整某一行的行高
void QTableView::resizeRowToContents ( int row ) [slot]
Resizes the given row based on the size hints of the delegate used to render each item in the row.
根据内容自动调整所有行的行高。
void QTableView::resizeRowsToContents () [slot]
Resizes all rows based on the size hints of the delegate used to render each item in the rows.
设置日志:我用了下,感觉没有打时间啊,而且比较粗糙。。。回头有时间自己加点代码完善下
#include <QtDebug> #include <QFile> #include <QTextStream> void customMessageHandler(QtMsgType type, const char *msg) { QString txt; switch (type) { //调试信息提示 case QtDebugMsg: txt = QString("Debug: %1").arg(msg); break; //一般的warning提示 case QtWarningMsg: txt = QString("Warning: %1").arg(msg); break; //严重错误提示 case QtCriticalMsg: txt = QString("Critical: %1").arg(msg); break; //致命错误提示 case QtFatalMsg: txt = QString("Fatal: %1").arg(msg); abort(); } QFile outFile("debuglog.txt"); outFile.open(QIODevice::WriteOnly | QIODevice::Append); QTextStream ts(&outFile); ts << txt << endl; } int main( int argc, char * argv[] ) { QApplication app( argc, argv ); //先注册自己的MsgHandler qInstallMsgHandler(customMessageHandler); //以后就可以像下面这样直接打日志到文件中,而且日志也会包含时间信息 qDebug("This is a debug message at thisisqt.com"); qWarning("This is a warning message at thisisqt.com"); qCritical("This is a critical message at thisisqt.com"); qFatal("This is a fatal message at thisisqt.com"); return app.exec(); }
发表评论
-
mac无法debug
2019-09-23 17:36 228升级新的lldb,底层脚本用的py3,而qtcreator暂不 ... -
现有项目生成pro文件
2018-07-21 15:32 1225qmake -project -
QtCreator使用arm编译器
2014-04-18 16:19 1185构建工具链各种不和谐,心一狠,直接改最原始的配置文件 1.首 ... -
qtcreator c++11
2013-07-15 22:10 846在.pro里面:QMAKE_CXXFLAGS += -std= ... -
qt webkit
2013-03-28 17:27 768arora是一个很不错的开源的浏览器,我说它不错并不见得它的性 ... -
qt profile
2012-05-29 17:04 5347这篇文章是我从360doc上转的,本来是要把转的url列出来的 ... -
QtConcurrent
2012-05-26 14:48 1970当我们想在一个或多个辅助线程执行的同时做一些后台处理且无须使用 ... -
QThreadPool
2012-05-23 22:24 2161#include<QThreadPool> ... -
用qtcreator但不用qt库
2012-04-17 10:48 1247pro file: QT -= core gui -
qtcreator缺少编码
2012-04-14 13:46 842将plugins/codecs复制到yourcreator/b ... -
Qt mysql相关
2011-11-28 23:44 1760sudo apt-get install mysql-serv ... -
Qt自定义事件
2011-08-31 14:48 5264先看下官方的文档:(google translation) Q ... -
QComboBox下拉item变灰
2011-07-21 10:10 1859qobject_cast<QStandardItemMo ... -
Qt国际化
2011-07-21 09:37 9151.先在.pro中加入一行:TRANSLATIONS = xx ... -
Qt读写xml
2011-07-20 10:49 6390test.xml <?xml version=&qu ... -
Qt多线程
2011-07-18 21:08 1415Qt中线程安全的类有QMutex,QMutexLocker,Q ... -
生产者与消费者
2011-07-16 09:42 2#include<iostream> #in ... -
Qt读写二进制文件
2011-07-11 22:11 5630DataStream.h #ifndef DATASTRE ... -
QItemDelegate
2011-07-09 10:57 1844.h #ifndef DIALOG_H #define ... -
Qt的文本文件读写
2011-07-02 17:00 3202mainwindow.h #ifndef MAINWIND ...
相关推荐
实现QFileSystemModel+QTableView创建文件管理系统,基于windows平台。 进一步优化该功能,为了适配嵌入式arm平台,实现QFileSystemModel的自定义修改图标功能。这样用户可以通过不同文件类型需求,自定义自己所要...
QTableView显示自定义CheckBox, 开发环境macos 10.13.1 Qt 5.9.1
如何设置编辑QTableView单元格时的字体颜色
QTableView 标题换行显示和富文本显示 ,多种代理,可以解决一些问题,有点贵,慎下载
QTableView同时显示自定义Checkbox和文件图标,开发环境macos 10.13.1 Qt 5.9.1
博客地址:https://blog.csdn.net/sinat_33859977/article/details/102776651
使用QTableView显示本地字段信息
主要介绍了Qt GUI图形图像开发之QT表格控件QTableView详细使用方法与实例,需要的朋友可以参考下
采用代理方式,实现qtableview的文字自动换行
1)分页显示列表功能包括:前后分页,指定页面跳转,设置单页显示条数 2)点击标题栏实现列表内容排序功能(这个功能花了我很长时间,在全网就没找到合适的解决方法,要不是参考了Qt开发经验,采用了变通解决办法才...
qtableview和model配合使用,实现较为复杂功能,如view中添加qcheckbox,图片,单击事件实现第等
QTableView+QComboBox简单使用。采用Qt代理的方式,用QComboBox做了指定列的代理。 功能: 1. 采用QComboBox作为QtableView某一列的代理 2. 可添加QtableView的项; 3. 可删除QtableView的项;
方法一:恰当的设置表格的列宽往往能给表格的美观性带来较好的效果。一种简单的方法是:调用表头的setSectionResizeMode()方法,代码如下:参数QH
配合博客: http://blog.csdn.net/zy19940906/article/details/75033090
1、QSqlDatabase实现数据库的基本功能,以及QTableView显示数据库表数据。 2、基本功能有: (1)增加数据的功能; (2)删除数据的功能; (3)修改数据的功能; (4)查找数据的功能; (5)用QTableView显示...
NULL 博文链接:https://tcspecial.iteye.com/blog/1955430
今天小编就为大家分享一篇PyQT5 QTableView显示绑定数据的实例详解,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
QTableView插入各种按钮,很好用
通过动态代理,在单元格中添加spinbox,checkbox,combobox。
QTableView添加复选框,下拉框控件