Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Return QpointF = nothing from QgraphicsItem to Mainwindows

Return QpointF = nothing from QgraphicsItem to Mainwindows

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 868 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • gfxxG Offline
    gfxxG Offline
    gfxx
    wrote on last edited by
    #1

    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

    bkt

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

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

      gfxxG 1 Reply Last reply
      0
      • ? A Former User

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

        gfxxG Offline
        gfxxG Offline
        gfxx
        wrote on last edited by
        #3

        @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

        bkt

        gfxxG 1 Reply Last reply
        0
        • gfxxG gfxx

          @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

          gfxxG Offline
          gfxxG Offline
          gfxx
          wrote on last edited by
          #4

          @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

          bkt

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved