[Qt-interest] QGraphicsItem as parent
Norbert Bokor
bokorn at tvn.hu
Wed Jul 22 23:42:02 CEST 2009
oops, i've just seen that my mail was sent to Alexis instead of the list...
it dies when executing the line i mentioned (pivots[dir] = new
QGraphicsLineItem(this))
gdb log:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb6cab920 (LWP 5555)]
0xb7cbb216 in QGraphicsItem::setPos () from /usr/lib/qt/lib/libQtGui.so.4
Alexis Menard wrote:
> Where it crashes? can you run this on gdb/or give me a backtrace?
>
> On Jul 20, 2009, at 23:05, Norbert Bokor wrote:
>
>> Hi Alexis,
>>
>>
>> relevant code (i try to paste as few as possible, i don't want to
>> flood the list):
>>
>> class AbstractNode : public QGraphicsWidget
>> {
>> Q_OBJECT
>> Q_ENUMS(PivotDirection)
>>
>> protected:
>> AbstractNode() : QGraphicsWidget() {}
>> const static int pivotlength = 16;
>>
>> public:
>> enum PivotDirection {Up=0, Down, Left, Right};
>>
>> QPointF getPivot(PivotDirection pivot) const;
>> QPointF getPivotPointFrom(AbstractNode *from) const;
>> QPointF getPivotPointTo(AbstractNode *to) const;
>> AbstractNode::PivotDirection getPivotFrom(AbstractNode
>> *from) const;
>> AbstractNode::PivotDirection getPivotTo(AbstractNode
>> *to) const;
>> QPointF getCenter() const;
>> };
>>
>>
>>
>> /******************************************
>> * GraphNode constructor
>> ******************************************/
>> GraphNode::GraphNode(QGraphicsScene *scene, int ownnr, const QString
>> &ntitle, const QString &nintro) : AbstractNode()
>> {
>> pivots[Left] = pivots[Right] = pivots[Up] = pivots[Down] = NULL;
>> foreach(PivotDirection dir, pivots.keys())
>> {
>> qWarning() << "--> " << dir;
>> pivots[dir] = new QGraphicsLineItem();
>> scene->addItem(pivots[dir]);
>> switch (dir)
>> {
>> case Left: pivots[dir]->setLine(QLineF( QPointF(0,
>> size().height()/2), QPointF(-pivotlength,size().height()/2))); break;
>> case Right: pivots[dir]->setLine(QLineF(
>> QPointF(size().width(), size().height()/2),
>> QPointF(size().width()+pivotlength,size().height()/2))); break;
>> case Up: pivots[dir]->setLine(QLineF(
>> QPointF(size().width()/2, 0), QPointF(size().width()/2,
>> -pivotlength))); break;
>> case Down: pivots[dir]->setLine(QLineF(
>> QPointF(size().width()/2, size().height()), QPointF(size().width()/2,
>> size().height()+pivotlength))); break;
>> }
>> pivots[dir]->hide();
>> pivots[dir]->setZValue(1000);
>> }
>> ....
>>
>>
>>
>> if i change pivots[dir] = new QGraphicsLineItem() to pivots[dir] =
>> new QGraphicsLineItem(this), it crashes
>>
>>
>>
>> Alexis Menard wrote:
>>> A Backtrace? More code please.
>>>
>>> On Jul 20, 2009, at 01:27, Norbert Bokor wrote:
>>>
>>>> Hi all,
>>>>
>>>> I have a class derived from QGraphicsWidget through an abstract class:
>>>>
>>>> QGraphicsWidget -> AbstractNode -> GraphNode
>>>>
>>>> when i create a new QGraphicsLineItem(this) (using my GraphNode
>>>> class as
>>>> parent), it crashes. if i don't set my class as parent of an other,
>>>> the
>>>> application runs and i can do anything with my GraphNode
>>>>
>>>> any idea/hint what's missing or what am i doing wrong?
>>>>
>>>>
>>>> thanks in advance
>>>>
>>>> _______________________________________________
>>>> Qt-interest mailing list
>>>> Qt-interest at trolltech.com
>>>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>>
>>>
>>
>
>
More information about the Qt-interest-old
mailing list