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. Repainting
Forum Update on Tuesday, May 27th 2025

Repainting

Scheduled Pinned Locked Moved General and Desktop
user interfaceqwidgetsubclassing
5 Posts 3 Posters 1.9k Views 2 Watching
  • 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.
  • D Offline
    D Offline
    David.G
    wrote on 25 May 2015, 20:47 last edited by
    #1

    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.

    I 1 Reply Last reply 26 May 2015, 01:54
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 25 May 2015, 22:36 last edited by
      #2

      Hi,

      Can you show the code of your paintEvent ?

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

      D 1 Reply Last reply 26 May 2015, 14:09
      0
      • D David.G
        25 May 2015, 20:47

        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.

        I Offline
        I Offline
        ileonte
        wrote on 26 May 2015, 01:54 last edited by ileonte
        #3

        @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.

        1 Reply Last reply
        0
        • S SGaist
          25 May 2015, 22:36

          Hi,

          Can you show the code of your paintEvent ?

          D Offline
          D Offline
          David.G
          wrote on 26 May 2015, 14:09 last edited by
          #4

          @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.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 26 May 2015, 22:44 last edited by
            #5

            Then what does your custom widget contain ?

            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

            3/5

            26 May 2015, 01:54

            • Login

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