被视为Qreal&

时间:2014-04-23 08:37:17

标签: c++ qt

我在qt代码中面临一些奇怪的问题

            qreal x1 = firstPoint.x();
            qreal y1 = firstPoint.y();
            qreal x2 = wid;
            qreal y2 = ht;

            OverlayLine* temp = qobject_cast<OverlayLine *>(overlayFact->createObject("Line",this));
            temp->setDimensions(x1, y1, x2, y2);
            temp->isMovable = true;
            temp->isUserRemovable = true;
            temp->isResizable = true;

函数setDimensions的原型如下

virtual void setDimensions(qreal x, qreal y, qreal w, qreal h);

但在编译时我收到此错误

错误:没有匹配函数来调用&#39; OverlayLine :: setDimensions(qreal&amp;,qreal&amp;,qreal&amp;,qreal&amp;)&#39;              temp-&gt; setDimensions(x1,y1,x2,y2);                                                ^

我错过了什么吗? 同样奇怪的是,如果我修改我的代码

            qreal x2 = wid;
            qreal y2 = ht;

            OverlayLine* temp = qobject_cast<OverlayLine *>(overlayFact->createObject("Line",this));
            temp->setDimensions(firstPoint.x(), firstPoint.y(), x2, y2);
            temp->isMovable = true;
            temp->isUserRemovable = true;
            temp->isResizable = true;

我收到以下错误

错误:没有匹配函数来调用&#39; OverlayLine :: setDimensions(qreal,qreal,qreal&amp;,qreal&amp;)&#39;              temp-&gt; setDimensions(firstPoint.x(),firstPoint.y(),x2,y2);                                                                        ^

0 个答案:

没有答案