QGraphicsView scaling

  • Hello,

    I'am playing with QGraphics and I encounter a problem with the following code.
    It is simply a red circle in a scene. Its dimension can be scaled with the "factor" variable.
    The view is scaled in order the circle has always the same size on the screen.

    When factor is 10 I can click the circle, but when factor is 1 It is as the shape was the boundingRect.

    I don't understand this behavior, is there is limit in item size ?

    Thanks a lot,


    @#include <QtGui>

    float dim = 5e-3;
    float scale = 20000;
    float factor = 1.;

    int main(int argc, char *argv[])
    QApplication app(argc, argv);
    dim = dim * factor;
    scale = scale / factor;

    QGraphicsView *view = new QGraphicsView;
    QGraphicsScene *scene = new QGraphicsScene;
    QRectF rect = QRectF(-dim, -dim, 2*dim, 2*dim);
    QGraphicsEllipseItem *item = new QGraphicsEllipseItem(rect, 0);
    item->setFlag(QGraphicsItem::ItemIsSelectable, true);
    item->setFlag(QGraphicsItem::ItemIsMovable, true);
    view->scale(scale, scale);
    return app.exec();


Log in to reply

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