Results 1 to 7 of 7

Thread: QPainter and how to access the parent variables.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QPainter and how to access the parent variables.

    Why update 50 times per second? Why not update only when something actually changes?

    You can access the parent though parent() and parentWidget(). Remember to cast the result to the proper class pointer (your QMainWindow descendant).

  2. #2
    Join Date
    Aug 2006
    Location
    The Netherlands
    Posts
    64
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QPainter and how to access the parent variables.

    Quote Originally Posted by wysota View Post
    Why update 50 times per second? Why not update only when something actually changes?
    There is a continu datastream arriving at the comport which need to be visualized, actually
    the data is coming from a 4 channel analog/digital-converter which generates 100 samples
    per second. So with 1200 pixels on the X-axe one trace takes 12 seconds (I paint one pixel
    per sample).
    Tnx for the tip, I'm going to try that.

    Regards.

  3. #3
    Join Date
    Aug 2006
    Location
    The Netherlands
    Posts
    64
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QPainter and how to access the parent variables.

    "mainwindow.h:140: error: ISO C++ forbids declaration of ‘PainterWidget’ with no type"

    I can't include mainwindow.h in painterwidget.h because in mainwindow.h I have already
    included painterwidget.h. If I don't include painterwidget.h in mainwindow.h I can not create
    a class PainterWiget. If I can't include mainwindow.h in painter.h, how do I cast the parent
    widget to the class used in mainwindow.cpp?

    I guess I got lost in C++...

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QPainter and how to access the parent variables.

    Quote Originally Posted by Teuniz View Post
    I guess I got lost in C++...
    Use forward declaration in headers. Further explanation: Circular dependency
    J-P Nurmi

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

    Default Re: QPainter and how to access the parent variables.

    Quote Originally Posted by Teuniz View Post
    There is a continu datastream arriving at the comport which need to be visualized, actually
    the data is coming from a 4 channel analog/digital-converter which generates 100 samples
    per second.
    But the human eye treats ~16fps as a smooth movement, so there is no point in refreshing the graph too often. I don't think a delay of several miliseconds will make you a difference in considering the data "real time".

  6. #6
    Join Date
    Aug 2006
    Location
    The Netherlands
    Posts
    64
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QPainter and how to access the parent variables.

    I read the article on Wikipedia and now it works
    I'm using a refreshrate of 16 fps as well

    Tnx wysota and jpn!

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.