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. Problem related to paint event?
Forum Updated to NodeBB v4.3 + New Features

Problem related to paint event?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.5k Views 1 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.
  • P Offline
    P Offline
    pratik041
    wrote on last edited by
    #1

    In my button class i am creating custom button using paint event but in some cases i want normal button. So the problem is that once i
    am including paint event function in my button class the normal button disappear. what is the solution to get normal button?

    Pratik Agrawal

    1 Reply Last reply
    0
    • EddyE Offline
      EddyE Offline
      Eddy
      wrote on last edited by
      #2

      You could use an if statement in your paintevent. In some cases as you call it, you can then use the ancestor paintevent. In the other cases use your custom behaviour.

      Qt Certified Specialist
      www.edalsolutions.be

      1 Reply Last reply
      0
      • P Offline
        P Offline
        pratik041
        wrote on last edited by
        #3

        but in this case also i will not get the normal button provided by qt because writing the paintevent with an empty definition itself making the normal button disappear.

        Pratik Agrawal

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          So, don't use an empty definition, but use

          @
          void MyButton::paintEvent(QPaintEvent* pe)
          {
          if (do_own_drawing) {
          //blah, do the drawing
          } else {
          QPushButton::paintEvent(pe); //assuming your button class inherits QPushButton
          }
          }
          @

          By the way, did you know that you can also customize the rendering of exiting buttons using style sheets? Not sure what you want to achieve, but that might be easier if you just want to modify the rendering of the button.

          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