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 7603119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:35:16+00:00 2026-05-30T23:35:16+00:00

How is it possible to customize the drawing algothithm of QPainterPath? I would like

  • 0

How is it possible to customize the drawing algothithm of QPainterPath?

I would like to speed up my app by painting only visible elements.

I am drawing real-time plot from QPainterPath and would like to do this:

  1. Binary search of leftmost visible element of QPainterPath.
  2. Binary search of rightmost visible element of QPainterPath.
  3. Draw only visible elements.

I think I should customize QPaintEngine of my QWidget via QWidget::paintEngine().

But QPaintEngine::drawPath(...) default implementation does nothing .

Am I right or not?

UPDATE:

Thanks for respounce, Koying.

I’ve just tryed this way:

int minIndex = BinarySearchForMatchOrGreat(path, beginOffset);
int maxIndex = BinarySearchForMatchOrGreat(path, endOffset);
QPainterPath newPath;
for (int i = minIndex; i < maxIndex; i++)
{
    const QPainterPath::Element & element = path.elementAt(i);
    newPath.moveTo(element.x, element.y);
}
painter.drawPath(newPath);

All works nice! I have fixed time overhead for any element count.

Have you any suggestions to speed up my code?

UDPATE:

I have error while reading QPainterPath and adding elements to it from another thread.
Sometimes app crashes with callstack:

QtCored4.dll!qt_message_output(QtMsgType msgType, const char * buf) Line 2240 C++
QtCored4.dll!qt_message(QtMsgType msgType, const char * msg, char * ap) Line 2298 + 0x12 bytes C++
QtCored4.dll!qFatal(const char * msg, …) Line 2481 + 0xf bytes C++
QtCored4.dll!qt_assert(const char * assertion, const char * file, int line) Line 1999 + 0x16 bytes C++
QtGuid4.dll!QPainterPath::elementAt(int i) Line 405 + 0x36 bytes C++
MyPlot.dll!MyPlot::paintEvent(QPaintEvent * event) Line 172 + 0x13 bytes C++

while calling elementAt(i), i == 4303 and there are 5459 elements.

Maybe element count is not real for moment of crash?

Can second thread modify element count while first thread is crashing?

This how works my threads:
My gui thread uses only read-only methods.
My second thread adds 1-5 thousands point per second.

  • 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-30T23:35:17+00:00Added an answer on May 30, 2026 at 11:35 pm

    QPaintEngine is an abstract interface to the underlying, platform-specific painting engine, i.e. GDI on on Windows, X on Linux, cocoa on Mac, etc… so is not what you are looking for.

    What you should do is edit your QPainterPath to remove the elements that you don’t want to be painted. QPainterPath is just a list of primitives, a bit like SVG, not some kind of bitmap.

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

Sidebar

Related Questions

I would like to know if it's possible to customize each row of listview?
I would like to know how it is possible to customize a NSMenu items
Is it possible to customize ProgressDialog in wxPython? For instance, I would like to
Is it possible to customize the call screen in Android? Example would be, two
GTK+ noob question here: Would it be possible to customize the GtkFileChooserButton or GtkFileChooserDialog
Is it possible to customize the Facebook Events app and hook in a user
Is it possible to customize the syntax highlighting in Visual Studio 2005? Up to
Is it somehow possible to customize or subclass System.Windows.Forms.ColorDialog to add a few buttons?
Is it possible to customize a django application to have accept localized date format
Hey Guys is it possible to customize an share option? I am exactly searching

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.