问题
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);
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:
'class QHeaderView' has no member named 'setResizeMode'
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:
'class QHeaderView' has no member named 'setSectionResizeMode'
...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.
回答1:
it may be that the QT header versions don't match up
double check the QT_VERSION_STR
in QtCore/qglobal.h
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
来源:https://stackoverflow.com/questions/18592228/qt-different-tablewidget-member-names-on-workstations