Qt:工作站上的不同tableWidget成员名称 [英] Qt: Different tableWidget member names on workstations

查看:155
本文介绍了Qt:工作站上的不同tableWidget成员名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在两台ubuntu机器上使用Qt,并不时在它们之间复制源代码.我这样做时发现了一个非常烦人的问题,我不知道为什么会发生.

我正在使用表格Widget显示一些数据,并希望拉伸水平标题以适合内容长度.为此,我使用以下行:

I am using Qt on two ubuntu machines and am copying the source code from time to time between them. I found a really annoying problem when doing that and I can't figure out why this happens.

I am using a table Widget to display some data and want to stretch the horizontal header to fit the content length. To do that I use the following line:

ui->tableWidget->horizontalHeader()->setResizeMode(0, QHeaderView::ResizeToContents);

这很好用. 我有一些这样的代码行. 但是,当我现在将源代码复制到另一台PC上工作时,出现以下编译错误:

This works just fine. I have a few of this codelines. However, when I now copy over my source code to the other PC to work on it, I get the following compile error:

类QHeaderView"没有名为"setResizeMode"的成员

'class QHeaderView' has no member named 'setResizeMode'

'setResizeMode'重命名为'setSectionResizeMode'可以很好地解决该问题,但是如果我现在将源代码复制回第一台PC,它会告诉您我:

Renaming 'setResizeMode' to 'setSectionResizeMode' will work just fine to fix that problem, but if I now copy the source code back to the first PC, it tells me:

类QHeaderView"没有名为"setSectionResizeMode"的成员

'class QHeaderView' has no member named 'setSectionResizeMode'

...并且我必须再次将其重命名为'setResizeMode',才能继续工作. 我在两台PC上都检查了Qt版本,它们都是基于"Qt 5.0.1(32位)" "Qt Creator 2.7.0" . 系统也是最新的. 唯一的区别是,我使用英语系统语言中的一种,使用德语系统中的另一种...但是我不知道这将如何影响Qt的成员声明. o.O

...and I have to rename it to 'setResizeMode' again, to continue working. I checked the Qt version on both PCs and they are both "Qt Creator 2.7.0" based on "Qt 5.0.1 (32 bit)". Also the systems are up to date. The only difference is, that I am using one of them in english system language, the other one in german...but I don't see how that would affect Qt's member declaration. o.O

任何人都知道问题出在哪里吗? 随着时间的推移,不断重命名会变得很烦人.

Anyone knows what the problem is? The constant renaming can get annoying over time.

推荐答案

QT标头版本可能不匹配

it may be that the QT header versions don't match up

仔细检查QtCore/qglobal.h

为了快速检查您是否太懒,请在代码中添加#pragma message("QT version: " QT_VERSION_STR),以使编译器在编译时将其输出

for a quick check if you are too lazy add a #pragma message("QT version: " QT_VERSION_STR) to the code to have the compiler output it while compiling

这篇关于Qt:工作站上的不同tableWidget成员名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆