Return QpointF = nothing from QgraphicsItem to Mainwindows



  • Hi,

    I try to get QPointF from My custom GraphicsItem ... with qDebug I see the correct point but nothing whet I try to call the return value from mainwindows .... my RectItem.h

    class RectItem : public QObject, public QGraphicsItem
    {
       Q_OBJECT
       Q_INTERFACES(QGraphicsItem)
    
    public:
    
        RectItem(QGraphicsItem* parent = 0);
    
        void getPoint(QPointF myPointBox);
    
        QRectF boundingRect() const { return rect; }
        QPointF lastP() const { return m_V; }
    
    /**** other void  ****/
    
    private:
        QRectF rect;
        QPointF m_V;
    
    }
    

    my RectItem.cpp ...

    void RectItem::getPoint(QPointF mypoint)
     { 
            m_V = myPointBox; 
            qDebug() << "show my calculated point:    "  << myPointBox;
            /*** exe these show 9,9 ****/
    }
    

    in my Mainwindows.h ...

    private:
        Ui::MainWindow *ui;
        RectItem* m_rect;
    

    in my Mainwindows.cpp ...

    RectItem* m_rect = new RectItem();
    m_rect->setRect(QRectF(i,e,w,h));
    
    /*** some stupid work *****/
    
    void Mainwindows::myvoid()
    {
           qDebug() << "my stupid point:  "  <<  m_rect->lastP();  /**** this show everytime 0,0 when it must show 9,9 ****/
    
    }
    
    

    obviuslly I make some stupid error ... but I not aBLE TO SEE IT ....

    Regards
    giorgio


  • Moderators

    Hi! The code you posted isn't complete enough to say where the bug is. Please show us more code.



  • @Wieland so the posted code does not give any warning? .... At these point not Know witch part of code can post .... I search around better .... then re-post.

    thanks
    Giorgio



  • @gfxx ... ok ok ....very :( error ...

    /class RectItem : public QObject, public QGraphicsItem
    {
      Q_OBJECT
      Q_INTERFACES(QGraphicsItem)
    
    public:
    
       RectItem(QGraphicsItem* parent = 0);
    
       void getPoint(QPointF myPointBox); /*** these pass value to lastP *****/
    
       QRectF boundingRect() const { return rect; }
       QPointF lastP() const { return m_V; }
    
    /**** other void  ****/
    
    private:
       QRectF rect;
       QPointF m_V;
    
    }
    
    

    in the getPoint void ... there are m_V = MyPointBox :(:(:( .... 3hour ....

    for furter reader:

    the right was:

    m_V.setX(MyPointBox.x());
    m_V.setY(MyPointBox.y());
    

    regards
    Giorgio


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.