Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6570369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:44:53+00:00 2026-05-25T14:44:53+00:00

I have two questions regarding the QGraphicsView Framework . The first question is regarding

  • 0

I have two questions regarding the QGraphicsView Framework.

The first question is regarding a special line: I wanted to ask whether it is possible to draw an Snake- or Wave-Line (like in the linked image)? I would be grateful for any solution, because I dont have any idea how to get the sinus-shaped line.

Image: a snake line

My second question is about the QGraphicsItemAnimation– I want to animate a QGraphicsLineItem. Right now I am using the method setPosAt() from the QGraphicsItemAnimation. The problem is, that the hole line is moved. My aim is to move only the start or the end point of the QGraphicsLineItem with the QGraphicsItemAnimation. So I want to ask whether this is possible or whether there is any other way to do something like this?

Thanks in advance!

Kind regards
– PhiGamma

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:44:53+00:00Added an answer on May 25, 2026 at 2:44 pm

    For the first part of your question : Probably a couple of ways:

    a. Use QPainterPath and the cubicTo() method to create the “path”, then use QGraphicsPath with the path you create. In order to do this, you’ll need to approximate the sinewave using bezier curves. Some info on that here, and the QPainterPath documentation is here

    b. Subclass QGraphicsItem() and override the paint() event to draw your path using QPainter.

    Sinewave::Sinewave( QGraphicsItem* pParent ) : QGraphicsObject( pParent)
    {
        m_bounds = QRectF(0,0,150,100);
    }
    
    QRectF Sinewave::boundingRect() const
    {
        return m_bounds;
    }
    
    void Sinewave::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
    {
        unsigned int i;
        QPointF last(0,50);
        const int numberOfCycles = 4.0;
        painter->setRenderHint(QPainter::Antialiasing);
    
        for (int i = 0; i < boundingRect().width(); i++)
        {
            double radians = numberOfCycles * 2.0 * PI * static_cast<double>(i) / boundingRect().width();
            double y = sin(radians);
            QPointF next(i, 50 + y*50);
            painter->drawLine(last, next);
            last = next;
        }
    }
    

    Which one you use would depend on what you want the object to do (e.g. do you need to change it’s shape at runtime?).

    For your question about animation – no, you can only apply transforms with QGraphcisItemAnimation. I would do it by using a QTimer to drive the change you want in your items in it’s timeout() slot.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two questions regarding to html table layout. First I will provide some
I have two questions regarding array: First one is regarding following code: int a[30];
I actually have two questions regarding the same problem but I think it is
I actually have two questions regarding exception/error handling in the iPhone app that I
I have a question regarding the two additional columns (timeCreated, timeLastUpdated) for each record
I have two questions regarding the multidimensional arrays. I declared a 3D array using
I have two questions regarding ceil() function.. The ceil() function is implemented in C.
I have two questions regarding python libraries: I would like to know if there
I have two questions regarding Erlang file i/o; what is the best way to
I have two questions regarding interfaces in Java. 1) If a class happens to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.