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. QPixmap::fill() usage

QPixmap::fill() usage

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 6.3k 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.
  • D Offline
    D Offline
    doru001
    wrote on last edited by
    #1

    In constructor:
    @ setBackgroundRole(QPalette::Dark);
    setAutoFillBackground(true);
    @
    Refresh:
    @ pixmap.fill(palette().color(QPalette::Window)); // it should work, but it does not - the background is light gray
    pixmap.fill(QPalette::Window); // it should not work, palette().Window is ColorRole, not QColor, but it works
    @

    Also, the explanation on QPixmap::fill() is unclear:
    [quote]The effect of this function is undefined when the pixmap is being painted on.[/quote]
    What does this mean, the effect of the function is undefined when the pixmap is being painted on from another thread while this function is called, or what?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mcosta
      wrote on last edited by
      #2

      Hi,

      "The effect of this function is undefined when the pixmap is being painted on" means that if you paint on Pixmap, and your code do because you set setAutoFillBackground(true), a fill call could not work properly.

      QColor has a constructor that accept a Qt::GlobalColor enum; an enum is an integer value, then passing other integer QPalette::Window it works

      Once your problem is solved don't forget to:

      • Mark the thread as SOLVED using the Topic Tool menu
      • Vote up the answer(s) that helped you to solve the issue

      You can embed images using (http://imgur.com/) or (http://postimage.org/)

      1 Reply Last reply
      0
      • D Offline
        D Offline
        doru001
        wrote on last edited by
        #3

        Thank you for your answer.

        [quote author="mcosta" date="1367931408"]Hi,

        "The effect of this function is undefined when the pixmap is being painted on" means that if you paint on Pixmap, and your code do because you set setAutoFillBackground(true), a fill call could not work properly.[/quote]
        But I always want to paint something before or after I fill the background. This is the point with the background, it allows you to see the foreground. It makes no sense. Plus, this comes from an example. The example is in qt4, this is true, and QPixamp::fill() has changed in qt5, but still, it works.
        [quote author="mcosta" date="1367931408"]QColor has a constructor that accept a Qt::GlobalColor enum; an enum is an integer value, then passing other integer QPalette::Window it works [/quote]
        The QColor constructor story works, but enums are integers in C only, in C++ the compiler rejects the usage of a different enum type as argument of a function. Also, QPalette:Window is 10, like Qt::cyan. I would have noticed cyan instead of black.

        Why does
        @
        pixmap.fill(palette().color(QPalette::Window));@
        not work?

        1 Reply Last reply
        0
        • D Offline
          D Offline
          doru001
          wrote on last edited by
          #4

          And this deserves a bump ... if anybody can explain these strange behaviors.

          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