Qt World Summit: Submit your Presentation


  • Hello,

    I'm trying to get myself on the right path here on understanding the things that goes within the paintEvent(QPaintEvent *).

    I use a FlowLayout, unaltered provided by the documentation here. Out of curiousity I mixed a custom widget (using QToolButton. In the end I decided against it for now because it made no sense to create a custom widget when QToolTip provides what I need.) with a standard one, and the custom wouldn't draw itself.

    Thing is, a standard widget(s) such as QPushButton/QRadioButton would render nicely on the FlowLayout. But whenever I used the custom widget, unless it was isolated from standard widgets it wouldn't render.

    So I was thinking, maybe I missed something? It works when you loop/add it ten times, but when you mix it with standard widgets it doesn't.

    Anyway, like I've mentioned I won't be using a custom widget but, at the same time I just want to understand why it behaved that way. There's not much to show in terms of code (just make QToolButton, or PushButton your base, add it, then add a standard widget. For me it was: (Layout: StandardWidget, Custom Widget, Custom Widget) Custom Widget wouldn't show up). I'm using QT 5.4.

  • Lifetime Qt Champion


    Can you show the code of your paintEvent ?

  • @David.G I think you need to implement minimumSizeHint() for your custom widget in order to prevent it from being resized to 0x0 pixels by the layout.

  • @SGaist Currently I don't have a paintEvent in place. I tried to look for more documentation on how I would go on drawing the widget. I wasn't planning to override it either since I don't have anything to render at the moment.

    I guess I should also leave a notice that I'm still learning Qt5 and I'm still pushing it the best I can to understand the framework and see how things work so maybe I missed something basic on it.

  • Lifetime Qt Champion

    Then what does your custom widget contain ?