Results 1 to 4 of 4

Thread: no match for call to (QPoint)(double) (double)

  1. #1
    Join Date
    Dec 2011
    Location
    Living in Spain 100km North of Valencia
    Posts
    13
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default no match for call to (QPoint)(double) (double)

    I am having a problem compiling a program that draws a polygon on a QGraphicsScene.
    The problem is the values supplied to QPoint. The error is 'no match for call to (QPoint)(double) (double)'.
    I have changed the variable data type to float and even int! With the same error (NOT double, of course).
    The hard coded values to the polygon line works.
    I have attached the relevant code.
    Any advice would be much appreciated.
    [CODEvoid DataDisplay::drawData()
    {
    QPen outlinePen(Qt::black);
    QPolygonF polygon;
    double x,y;

    QPoint p1,p2;
    x = 10.4;
    y = 20.5;

    p1(10.4,20.5);
    x = 120.2;
    y = 30.2;
    p2(x,y);
    // polygon << QPointF((float)10.4, (float)20.5) << QPoint((float)120.2, (float)30.2);
    polygon << p1 << p2;

    outlinePen.setWidth(2);
    QGraphicsScene *scene = new QGraphicsScene(this);
    ui->graphicsView->setScene(scene);

    QBrush greenBrush(Qt::green);
    QBrush blueBrush(Qt::blue);
    outlinePen.setWidth(2);

    scene->addPolygon(polygon, outlinePen);
    }][/CODE]

  2. #2
    Join Date
    Oct 2009
    Location
    Mexico
    Posts
    81
    Thanks
    6
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: no match for call to (QPoint)(double) (double)

    you need use QPointF class instead of QPoint,

  3. #3
    Join Date
    Dec 2011
    Location
    Living in Spain 100km North of Valencia
    Posts
    13
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: no match for call to (QPoint)(double) (double)

    Thank you
    I tried that. It didn't work.
    The following does:
    void DataDisplay::drawData()
    {
    QPen outlinePen(Qt::black);
    QPolygonF polygon;
    qreal x1,y1,x2,y2;

    QPointF p1,p2;
    x1 = 10.8;y1=20.1;
    x2 = 120.2;y2=30.2;
    p1.setX(x1);
    p1.setY(y1);
    p2.setX(x2);
    p2.setY(y2);

    // polygon << QPointF((float)10.4, (float)20.5) << QPoint((float)120.2, (float)30.2);
    polygon << p1 << p2;

    outlinePen.setWidth(2);
    QGraphicsScene *scene = new QGraphicsScene(this);
    ui->graphicsView->setScene(scene);

    QBrush greenBrush(Qt::green);
    QBrush blueBrush(Qt::blue);
    outlinePen.setWidth(2);

    scene->addPolygon(polygon, outlinePen);
    }

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: no match for call to (QPoint)(double) (double)

    Qt Code:
    1. p1(10.4,20.5);
    To copy to clipboard, switch view to plain text mode 
    This is the line that causes the compilation error. The error message is telling you that the QPoint (and QPointF) class has no method with the signature:
    Qt Code:
    1. void QPoint::operator()( double arg1, double arg2 );
    To copy to clipboard, switch view to plain text mode 
    which is what your expression translates to. I think you are confusing this with a constructor. You could simply replace this line with this assignment (after changing p1 to QPointF):
    Qt Code:
    1. p1 = QPointF( x1, y1 );
    To copy to clipboard, switch view to plain text mode 
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 7
    Last Post: 5th January 2016, 14:44
  2. Error: No match for call to '(QPoint)()'
    By GT Development in forum Qt Programming
    Replies: 5
    Last Post: 11th October 2011, 08:24
  3. Program not finding an existing double in a QList<double>
    By aarelovich in forum Qt Programming
    Replies: 2
    Last Post: 9th May 2011, 20:59
  4. Replies: 2
    Last Post: 24th June 2009, 15:38
  5. Replies: 3
    Last Post: 5th June 2009, 19:19

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.