Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Repainting

    General and Desktop
    user interface qwidget subclassing
    3
    5
    1303
    Loading More Posts
    • 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.G
      David.G last edited by

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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.G 1 Reply Last reply Reply Quote 0
        • I
          ileonte @David.G last edited by ileonte

          @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 Reply Quote 0
          • David.G
            David.G @SGaist last edited by

            @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 Reply Quote 0
            • SGaist
              SGaist Lifetime Qt Champion last edited by

              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 Reply Quote 0
              • First post
                Last post