Results 1 to 10 of 10

Thread: Confusion with QPoint

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Posts
    87
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default Re: Confusion with QPoint

    here is the rest of the error message - hope this helps:

    sortingbox.cpp: In member function `virtual void SortingBox:aintEvent(QPaintEv
    ent*)':
    sortingbox.cpp:125: warning: left-hand operand of comma has no effect
    sortingbox.cpp:125: error: no matching function for call to `QRect::QRect(QPoint
    &, int, QString)'
    C:/Qt/4.0.1/include/QtCore/../../src/corelib/tools/qrect.h:37: note: candidates
    are: QRect::QRect(const QRect&)
    C:/Qt/4.0.1/include/QtCore/../../src/corelib/tools/qrect.h:183: note:
    QRect::QRect(int, int, int, int)
    C:/Qt/4.0.1/include/QtCore/../../src/corelib/tools/qrect.h:199: note:
    QRect::QRect(const QPoint&, const QSize&)
    C:/Qt/4.0.1/include/QtCore/../../src/corelib/tools/qrect.h:191: note:
    QRect::QRect(const QPoint&, const QPoint&)
    C:/Qt/4.0.1/include/QtCore/../../src/corelib/tools/qrect.h:39: note:
    QRect::QRect()

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: Confusion with QPoint

    How did you declare that shapeItem variable?

  3. #3
    Join Date
    Feb 2006
    Posts
    87
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default Re: Confusion with QPoint

    basically what i am wanting to do is display a number inside a circle which gets displayed at shapteItem.position(). my code for the displaying of the circes is like below:

    QPainter painter(this);

    foreach (ShapeItem shapeItem, shapeItems)
    {
    QPoint text(100,100);
    QPoint mid(shapeItem.position())

    painter.translate(shapeItem.position());
    painter.setBrush(shapeItem.color());
    painter.drawPath(shapeItem.path());
    painter.translate(-shapeItem.position());
    painter.setPen(initialItemColor());
    painter.drawText(QRect(mid,text),0,tr("%1").arg(sh apeItem.instanceNumber()));

    }

    ShapeItem is a class in another fle named ShapeItem.cpp and the shapeItem.position was decared in the header file as :

    void setPosition(const QPoint &position); and QPoint position() const; where the QPoint is a private variable. my function inside shapeItem is then as follows:

    QPoint ShapeItem:osition() const
    {
    return myPosition;
    }

    and:

    void ShapeItem::setPosition(const QPoint &position)
    {
    myPosition = position;
    }

    hope that helps, cheers

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: Confusion with QPoint

    All looks OK here.

    Is that the first error you get?

  5. #5
    Join Date
    Feb 2006
    Posts
    87
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    6
    Thanked 1 Time in 1 Post

    Unhappy Re: Confusion with QPoint

    i got it to work using the following code: QPoint mid(shapeItem.position()); but it doesnt display anything on the screen for some bizarre reason when i try to draw it with this:

    painter.setPen(initialItemColor());
    painter.drawText(QRect(mid,text),0,tr("%1").arg(sh apeItem.instanceNumber()));

    i think its a lost hope cos i cant think of aything else to use???!!

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: Confusion with QPoint

    What does this output?
    Qt Code:
    1. painter.setPen( initialItemColor() );
    2. QRect r(mid,text);
    3. qWarning( "x=%d y=%d w=%d h=%d", r.x(), r.y(), r.width(), r.height() );
    4. painter.drawText( r, QString::number( shapeItem.instanceNumber() ) );
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Feb 2006
    Posts
    87
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    6
    Thanked 1 Time in 1 Post

    Thumbs up Re: Confusion with QPoint

    i managed to get it working. i was kinda simple in the end, maybe i wasnt explaining my problem properly. all i did was just change the parameters for the drawText function. to the following:

    painter.drawText((shapeItem.position( )),tr("%1").arg(shapeItem.instanceNumber()));


    thanks for your help - much appreciated. Jag

Similar Threads

  1. Little confusion Regarding general Initilizaion..!!!
    By kunalnandi in forum General Programming
    Replies: 19
    Last Post: 11th October 2008, 13:29
  2. Little confusion Regarding general Initilizaion.. :confused:
    By kunalnandi in forum General Programming
    Replies: 2
    Last Post: 19th September 2008, 11:06
  3. QPoint Limitation
    By archanasubodh in forum Qt Programming
    Replies: 1
    Last Post: 5th August 2008, 11:22
  4. How find QPoint from a QListWidgetItem inside viewport?
    By patrik08 in forum Qt Programming
    Replies: 1
    Last Post: 12th April 2008, 13:28
  5. QTableView paints too much
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 26th July 2006, 19:42

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.