环境:vs2017+Qt5.9.7+windows

问题描述:

Qt QTableWidget使用中setText()和Text()使用崩溃

如图所示,使用tablewidget时,qmake、编译能过,调试时卡在setText和text报错,

原因分析:tablewidget的行列数是够的,后来发现是因为item的原因,tablewidget的每个表格上面都是需要新建item,然后在item的基础上进行text和setText,此处直接使用,会出问题,需要在前面定义一个item,然后tablewidget使用setitem,如下图:

Qt QTableWidget使用中setText()和Text()使用崩溃

此处还对显示文字的居中及表格背景做处理。

相关文章:

  • 2021-12-14
  • 2021-10-29
  • 2021-06-15
  • 2022-12-23
  • 2021-07-24
  • 2021-06-15
  • 2021-11-22
  • 2021-09-02
猜你喜欢
  • 2022-03-04
  • 2021-07-15
  • 2021-10-16
  • 2021-08-16
  • 2021-09-27
  • 2021-10-13
  • 2022-02-09
相关资源
相似解决方案