I have constructed my first piece of software using QT and C++, which is working perfectly when compiled on Ubuntu 11.04 and Mac OS X. When I compile on Windows, I get strange output in my GUI. I have tracked down the problem to an error calculating the paint coordinates. This is the offending calculation:
long x = ((pos-from) *width)/range ;
qDebug() << ***************;
qDebug() << "pos" <<"\t" << pos;
qDebug() << "from" <<"\t" << from;
qDebug() << "width" <<"\t" << width;
qDebug() << "range" <<"\t" << range;
qDebug() << "x" <<"\t" << x;
qDebug() << "***************";
And output from Ubuntu:
***************
pos 2500000
from 1
width 1005
range 4411537
x 569
***************
And the output from Windows:
***************
pos 2500000
from 1
width 1574
range 4411537
x -81
***************
Does anybody have an idea why I might be getting different values for x ?
Cheers.
long type in Windows is 32-bit.
You should use long long -type if you want 64-bits len or qint64 when you use Qt.