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. QGraphicsView/QGraphicsScene rotating wheel
Qt 6.11 is out! See what's new in the release blog

QGraphicsView/QGraphicsScene rotating wheel

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 424 Views
  • 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.
  • C Offline
    C Offline
    carre
    wrote on last edited by
    #1

    Hi,
    i need a rotating wheel and with this code it is nearly possible (without any stucks)

    wheelWidget::wheelWidget(QWidget *parent) : QGraphicsView(parent)
    {
    this->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);

    setViewport(new QOpenGLWidget);
    
    this->setViewportUpdateMode(QGraphicsView::NoViewportUpdate);
    
    wheel_pix = QPixmap(":/wheel.png");
    
    this->setOptimizationFlags(QGraphicsView::DontSavePainterState | QGraphicsView::DontAdjustForAntialiasing);
    this->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
    
    this->setAttribute(Qt::WA_NoSystemBackground);
    
    QGraphicsScene *scene = new QGraphicsScene(this);
    scene->setItemIndexMethod(QGraphicsScene::NoIndex);
    setScene(scene);
    
    QLabel *rotateWheel = new QLabel();
    rotateWheel->setPixmap(wheel_pix);
    rotateWheel->setStyleSheet("background: transparent");
    
    QGraphicsProxyWidget *rotateWheelItem = scene->addWidget(rotateWheel);
    rotateWheelItem->setTransformOriginPoint((qreal)rotateWheel->width()/(qreal)2, (qreal)rotateWheel->height()/(qreal)2);
    
    rotateWheel_animation = new QPropertyAnimation(rotateWheelItem, "rotation", this);
    rotateWheel_animation->setDuration(14400); 
    rotateWheel_animation->setEasingCurve(QEasingCurve::InOutCubic);
    
    connect(this, SIGNAL(start_now_wheel()), rotateWheel_animation, SLOT(start()));
    connect(rotateWheel_animation, SIGNAL(finished()), this, SLOT(animation_wheel_finish()));
    

    ..

    The dimension of this png is 401*401 pixel. The problem is, if i have a additional running progress bar on the main window, the wheel runs with micro lag. What i know it is not possible to put the widgets in different threads. But it seems that the running progress bar interrupt the rotating wheel display (micro - but visible). The OptimizationFlags helps nothing in this case. Have anyone maybe a idea what i can do on such situation?

    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