Qt4-preview-feedback Archive, March 2007
Patch for diagramitem.cpp to fix compiler error on RHEL3
Message 1 in thread
On RHEL3, the diagramitem.cpp file in ./examples/tools/undoframework/
doesn't compile for me because of some weird quirkwith g++ 3.2.3. It
doesn't like to have (qrand() % 256) inside the QColor constructor
arguments. Weird. I've attached a patch that fixes it for me.
--Dave
--- examples/tools/undoframework/diagramitem.cpp 2007-03-21 13:34:45.000000000 -0600
--- examples/tools/undoframework/diagramitem.cpp 2007-03-21 13:34:45.000000000 -0600
+++ examples/tools/undoframework/diagramitem.cpp 2007-03-23 08:57:01.000000000 -0600
@@ -20,6 +20,7 @@
****************************************************************************/
#include <QtGui>
+#include <QtGlobal>
#include "diagramitem.h"
@@ -37,8 +38,10 @@
setPolygon(trianglePolygon);
}
- QBrush brush(QColor(uint(qrand()) % 256, uint(qrand()) % 256,
- uint(qrand()) % 256));
+ int r = qrand() % 256;
+ int g = qrand() % 256;
+ int b = qrand() % 256;
+ QBrush brush(QColor(r,g,b));
setBrush(brush);
setFlag(QGraphicsItem::ItemIsSelectable);
setFlag(QGraphicsItem::ItemIsMovable);
Message 2 in thread
Dave Smith wrote:
> On RHEL3, the diagramitem.cpp file in ./examples/tools/undoframework/
> doesn't compile for me because of some weird quirkwith g++ 3.2.3. It
> doesn't like to have (qrand() % 256) inside the QColor constructor
> arguments. Weird. I've attached a patch that fixes it for me.
Do you need to both move the qrand code out of the initializer list, and
include QtGlobal, for this to compile? Are you sure it's not just the cast
to uint that causes the bug?
Andreas
--
[ signature omitted ]
Message 3 in thread
Andreas Aardal Hanssen wrote:
> Dave Smith wrote:
>
>> On RHEL3, the diagramitem.cpp file in ./examples/tools/undoframework/
>> doesn't compile for me because of some weird quirkwith g++ 3.2.3. It
>> doesn't like to have (qrand() % 256) inside the QColor constructor
>> arguments. Weird. I've attached a patch that fixes it for me.
>>
>
> Do you need to both move the qrand code out of the initializer list, and
> include QtGlobal, for this to compile? Are you sure it's not just the cast
> to uint that causes the bug?
Double checking now. Apparently the QtGlobal include is not necessary.
And the latest snapshot 20070325 seems to compile for me. It looks like
just removing the uint cast fixes it. No need to break out the
declaration of the int r, g, b. Here's the line from the latest snapshot
that works for me without modification:
QColor color(qrand() % 256, qrand() % 256, qrand() % 256);
Thanks!
--Dave
To unsubscribe - send "unsubscribe" in the subject to qt4-preview-feedback-request@xxxxxxxxxxxxx