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. Widget with custom paintEvent is not drawing

Widget with custom paintEvent is not drawing

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 443 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.
  • J Offline
    J Offline
    J.B. Langston
    wrote on last edited by
    #1

    I am the maintainer of XaoS. It has an optional Qt GUI, whose source is here. I have a custom FractalWidget that overrides paintEvent to draw a QImage, whose pixel buffer XaoS directly writes into. This code used to work under Qt4 and I believe earlier versions of Qt5 as well. Actually, it still works in Windows, but in Linux, the widget just stays black. (I am running Ubuntu 18.04, using the included Qt 5.9 libraries) I also have a different code path using paintGL, which still works, and I can enable by defining USE_OPENGL in my code. However, I want to get the standard paintEvent working as well in case users have ancient graphics cards that don't do Open GL well.

    Can someone take a look at my code and tell me what I'm doing wrong? If there are any questions about the code I will try to answer them.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Where are you filling these QImages from ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • J Offline
        J Offline
        J.B. Langston
        wrote on last edited by J.B. Langston
        #3

        XaoS has a system of pluggable filters, each of which writes directly to the pixel buffers The filters are in a queue, and each filter modifies the pixel buffer based on the output of the previous filter. Eventually, once all the filters have had a pass, the image is drawn on screen. There is an image struct which contains pointers to the pixel buffers, and info such as the width, height, row stride, R/G/Bmasks, and so forth. The create_image_cont function creates the image struct with the pixel buffer created by the QImage. It is called here and takes its information about the image format from the ui_driver structure defined here. The most important of the filters is the zoom filter that does the actual fractal calculation. The line of code where the zoom filter actually writes to the buffer is here.

        It's all pretty complicated, but all you really need to know is that various filters write to the buffers based on the width, height, stride, and R/G/B mask defined in the ui_driver struct. This abstraction makes XaoS flexible and has allowed it to be ported to many different APIs with minimal effort, on systems as diverse as Xlib, Windows, Mac OS X, GTK+, Qt, even DOS.

        I'm pretty sure the problem is not with the contents of the pixel buffer, because the code works on all the other systems, as well as on earlier versions of Qt, and even Qt 5 on windows. It's just on Linux with Qt 5.9 that it doesn't work.

        1 Reply Last reply
        0
        • J Offline
          J Offline
          J.B. Langston
          wrote on last edited by
          #4

          It was because I had set Qt::WA_PaintOnScreen on my widget. Removing that fixed the problem.

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved