Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Using QFont -- Getting Errors
Forum Updated to NodeBB v4.3 + New Features

Using QFont -- Getting Errors

Scheduled Pinned Locked Moved Qt Creator and other tools
4 Posts 3 Posters 4.8k 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
    RichardM198030
    wrote on last edited by
    #1

    Hello, I have included a link below to my sources, I can't get QFont to work, I looked at some examples and google, it throws this same error:
    ContactManager.cpp: In constructor ‘ContactManager::ContactManager()’:
    ContactManager.cpp:9:36: error: no matching function for call to ‘QLabel::setFont(QFont*&)’
    ContactManager.cpp:9:36: note: candidate is:
    /usr/include/QtGui/qwidget.h:331:10: note: void QWidget::setFont(const QFont&)
    /usr/include/QtGui/qwidget.h:331:10: note: no known conversion for argument 1 from ‘QFont*’ to ‘const QFont&’

    I have

    @
    QFont *colorFont; // Variable

    colorFont = new QFont("Sans Serif", 10, QFont::Bold)); // Removed that source.

    colorfont = new QFont(QFont("Sans Serif"), 10, QFont::Bold, true);
    @

    I tried it both ways, same error, if anybody can help solve this, thanks !!

    http://pastebin.com/khLKKUv0 You are allowed to post links, right? thanks in advance !!

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on last edited by
      #2

      In ContactManager.cpp line 9, you are trying to set a font by passing a pointer to the font into the function, while it expects you to pass a const reference (practically pass by value).

      You're doing:
      @QFont *font;
      label->setFont(font);@
      while you should be doing
      @QFont *font;
      label->setFont(*font);@

      "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
        RichardM198030
        wrote on last edited by
        #3

        [quote author="Franzk" date="1306008533"]In ContactManager.cpp line 9, you are trying to set a font by passing a pointer to the font into the function, while it expects you to pass a const reference (practically pass by value).

        You're doing:
        @QFont *font;
        label->setFont(font);@
        while you should be doing
        @QFont *font;
        label->setFont(*font);@[/quote]

        Yeah, I want the font to be bold, also, couldn't find any easy explanations of QColor, any good references you can link me to?? I'm assuming QLabel does support the Palette?

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

          Have a look at style sheets.
          You can experiment with it in Qt Designer. For instance have a QLabel in a form. Right mouse button click. Change style sheet ... Color ... foreground color.

          Using style sheets you can even control the colors and looks of you entire application instead of doing this one widget at a time.

          Qt Certified Specialist
          www.edalsolutions.be

          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