ajo
12th April 2013, 11:41
I'm trying to draw an image like the radial gradient one in the Qt gradients example, working with:
Qt 5.0.1 (64 bit) Qt Creator 2.6.2
on a Mac with OS X 10.8.3 (Mountain Lion)
It gives an memory access error and points to the line where the brush is constructed, whether brush is a pointer or not.
ballItem::ballItem()
{
QGradient gradient;
gradient.setSpread(QGradient::PadSpread);
// brush = new QBrush(gradient);
QBrush brush2(gradient);
}
This is the header:
#include <QGraphicsItem>
class ballItem : public QGraphicsItem
{
public:
ballItem();
protected:
QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
private:
QBrush* brush;
};
I was trying to use this QBrush constructor:
QBrush::QBrush(const QGradient & gradient)
I would appreciate it if somebody can show me my error.
Added after 40 minutes:
It seems that QConicalGradient, QLinearGradient or QRadialGradient needs to be used, not QGradient, because the QGradient type isn't initialized.
http://lists.trolltech.com/qt-jambi-interest/2007-05/thread00025-0.html
Qt 5.0.1 (64 bit) Qt Creator 2.6.2
on a Mac with OS X 10.8.3 (Mountain Lion)
It gives an memory access error and points to the line where the brush is constructed, whether brush is a pointer or not.
ballItem::ballItem()
{
QGradient gradient;
gradient.setSpread(QGradient::PadSpread);
// brush = new QBrush(gradient);
QBrush brush2(gradient);
}
This is the header:
#include <QGraphicsItem>
class ballItem : public QGraphicsItem
{
public:
ballItem();
protected:
QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
private:
QBrush* brush;
};
I was trying to use this QBrush constructor:
QBrush::QBrush(const QGradient & gradient)
I would appreciate it if somebody can show me my error.
Added after 40 minutes:
It seems that QConicalGradient, QLinearGradient or QRadialGradient needs to be used, not QGradient, because the QGradient type isn't initialized.
http://lists.trolltech.com/qt-jambi-interest/2007-05/thread00025-0.html