Results 1 to 5 of 5

Thread: qt drawing like a banner.

  1. #1
    Join Date
    Jun 2011
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default qt drawing like a banner.

    Hi everybody,

    I need a suggestion from you. I have to draw points collected from an external data provider micro controller, continuously. Basically, it is like drawing a curve, from left to right between two Y values, continuously. So, when a value reach the right margin, the drawing does not stop, but continue to draw point on screen. Ex. print the sin function from left to right continuously. Do you have any idea how to do it? thx for any suggestions.

    Cheers,

  2. #2
    Join Date
    May 2011
    Posts
    239
    Qt products
    Qt4
    Platforms
    Unix/X11 Symbian S60
    Thanks
    4
    Thanked 35 Times in 35 Posts

    Default Re: qt drawing like a banner.

    Create a widget on-screen, but don't draw directly on it.

    Instead, create a bitmap or image to draw on. Each time you draw another point, copy the whole image to the widget.

    Now, here's the trick: When you get to the right edge, make room to the new data point by copying it to the left (copy a region slightly offset from the left edge, to the right edge, using for example QImage::Copy() & QPainter:rawImage() to "paste" it extend the cordinate axises a bit and draw the new data points. This will get nice scrolling of the display.

    You may need to think of the widget as having perhaps many rectangles that are updated in different ways.

  3. #3
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    3
    Thanked 453 Times in 435 Posts
    Wiki edits
    15

    Default Re: qt drawing like a banner.

    You can try exploring Qwt

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: qt drawing like a banner.

    There is a different trick one might use to avoid unnecessary moving of data. Use more than one pixmap --- when you have no space left in the pixmap, create another one and start filling it with data. Once you have more pixmaps than can fit the display, remove the first pixmap to free memory.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jun 2011
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: qt drawing like a banner.

    Thanks a lot guys, yours ideas are very good. In the meanwhile I checked for the QWT plugin and downloaded the source code with examples. There is one that helps for this case, and it is the "oscilloscope" one. Very cool example because you can change the frequency, interval, time, etc. But (there is always a but ), when checking at the plot.cpp file, I got stacked in the updateCurve() and incrementInterval() functions. It speaks about a "clip" and honestly I cannot follow the logic of the code. If you have time (or ever have locked at it), would be nice what this all mean. I really appreciate again your time.
    Hope you can help me out
    Cheers,

Similar Threads

  1. Drawing in QML
    By JeffC in forum Newbie
    Replies: 10
    Last Post: 10th June 2011, 18:25
  2. how to add ad banner instead of title bar??
    By ram4soft in forum Newbie
    Replies: 4
    Last Post: 20th February 2011, 08:03
  3. Conceptual Question; QLabel as Banner?
    By SneakyPeterson in forum Newbie
    Replies: 5
    Last Post: 28th June 2010, 08:18
  4. QWizard and banner pixmap
    By desch in forum Qt Programming
    Replies: 8
    Last Post: 7th January 2008, 10:28
  5. QHeaderView as a banner
    By mclark in forum Qt Programming
    Replies: 1
    Last Post: 21st March 2007, 19:28

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
  •  
Qt is a trademark of The Qt Company.