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. Weird error: "2 overloads have no legal conversion"
Forum Updated to NodeBB v4.3 + New Features

Weird error: "2 overloads have no legal conversion"

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 6.2k 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.
  • R Offline
    R Offline
    reactive
    wrote on 28 Feb 2011, 15:29 last edited by
    #1

    I have some code that is setting a color in a QMainWindows palette. It works fine if I have:

    @
    QPalette p = win->palette();
    p.setColor(QPalette::Window, Qt::white);
    @

    But it throws the error "QPalette::setColor 2 overloads have no legal conversion for 'this' pointer" if I have this:

    @
    (win->palette()).setColor(QPalette::Window, Qt::white);
    @

    Can anyone explain this error to me?

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on 28 Feb 2011, 15:34 last edited by
      #2

      QWidget::palette() returns a const object. Do it properly:
      @
      QPalette p = win->palette();
      p.setColor(QPalette::Window, Qt::white);
      win->setPalette(p);
      @

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • R Offline
        R Offline
        reactive
        wrote on 28 Feb 2011, 15:38 last edited by
        #3

        D'oh! I'm relatively new to C++ and I forgot that the assignment ("=") makes a copy. Thanks!

        1 Reply Last reply
        0

        1/3

        28 Feb 2011, 15:29

        • Login

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