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
QtWS25 Last Chance

Repainting

Scheduled Pinned Locked Moved General and Desktop
user interfaceqwidgetsubclassing
5 Posts 3 Posters 1.8k 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.
  • David.GD Offline
    David.GD Offline
    David.G
    wrote on 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
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on 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

      David.GD 1 Reply Last reply
      0
      • David.GD David.G

        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 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
        • SGaistS SGaist

          Hi,

          Can you show the code of your paintEvent ?

          David.GD Offline
          David.GD Offline
          David.G
          wrote on 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
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on 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

            • Login

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