Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Hello World "pixelSize is not a member of QFont" (similar w/ "family")
Forum Updated to NodeBB v4.3 + New Features

Hello World "pixelSize is not a member of QFont" (similar w/ "family")

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
7 Posts 4 Posters 836 Views 2 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
    paulpv
    wrote on last edited by paulpv
    #1

    I am just starting off learning Qt/Qml/Qt-Quick.
    (For reference, I have been a professional software developer for 25+ years, so I'm not a total noob)

    Installation wasn't uneventful.
    I did not know which of packages in the Online Installer to choose.
    "Custom" was selected by default, so I went with it.
    My first installation I just left the default selected packages, which wasn't very many.
    I fired up Qt Creator and it didn't see any "Kits".
    I guess that I needed to select at least MSVC or MinGW.
    At the time I did not know there was a MaintenanceTool.exe, so I uninstalled and re-installed and selected Qt 5.15.2 MSVC 2019 64-bit and WinGW 64-bit.
    8405866d-549e-4707-944c-cb34fb29fdf0-image.png

    I fired up Qt Creator and created a Qt Quick Hello World project.
    I made one tiny edit to add a Text and set a font size according to another code guide that I am following that uses Qt 5.14.2:
    706c2318-c9c7-477c-b710-1be344567ec8-image.png

    The auto completion does show there is no pixelSize.
    Yet QFont says it does:
    https://doc.qt.io/qt-5/qfont.html#setPointSize

    Is this some legacy way of setting a font size? 5.14.2 wasn't that long ago, was it?
    Am I missing some syntactic sugar?
    What is the current way to set font size and family?

    Odd that even though this gives a red warning (which I take as an error), but the code actually runs! :/

    What am I doing wrong?

    Thanks!

    KroMignonK 1 Reply Last reply
    0
    • MarkkyboyM Offline
      MarkkyboyM Offline
      Markkyboy
      wrote on last edited by
      #2

      font.pixelSize is generally part of Text or Label, not ApplicationWindow or Window.

      Don't just sit there standing around, pick up a shovel and sweep up!

      I live by the sea, not in it.

      P 1 Reply Last reply
      0
      • MarkkyboyM Markkyboy

        font.pixelSize is generally part of Text or Label, not ApplicationWindow or Window.

        P Offline
        P Offline
        paulpv
        wrote on last edited by
        #3

        @Markkyboy Thanks. I realized that and updated my original question.

        1 Reply Last reply
        0
        • P paulpv

          I am just starting off learning Qt/Qml/Qt-Quick.
          (For reference, I have been a professional software developer for 25+ years, so I'm not a total noob)

          Installation wasn't uneventful.
          I did not know which of packages in the Online Installer to choose.
          "Custom" was selected by default, so I went with it.
          My first installation I just left the default selected packages, which wasn't very many.
          I fired up Qt Creator and it didn't see any "Kits".
          I guess that I needed to select at least MSVC or MinGW.
          At the time I did not know there was a MaintenanceTool.exe, so I uninstalled and re-installed and selected Qt 5.15.2 MSVC 2019 64-bit and WinGW 64-bit.
          8405866d-549e-4707-944c-cb34fb29fdf0-image.png

          I fired up Qt Creator and created a Qt Quick Hello World project.
          I made one tiny edit to add a Text and set a font size according to another code guide that I am following that uses Qt 5.14.2:
          706c2318-c9c7-477c-b710-1be344567ec8-image.png

          The auto completion does show there is no pixelSize.
          Yet QFont says it does:
          https://doc.qt.io/qt-5/qfont.html#setPointSize

          Is this some legacy way of setting a font size? 5.14.2 wasn't that long ago, was it?
          Am I missing some syntactic sugar?
          What is the current way to set font size and family?

          Odd that even though this gives a red warning (which I take as an error), but the code actually runs! :/

          What am I doing wrong?

          Thanks!

          KroMignonK Offline
          KroMignonK Offline
          KroMignon
          wrote on last edited by
          #4

          @paulpv said in Hello World "pixelSize is not a member of QFont" (similar w/ "family"):

          Odd that even though this gives a red warning (which I take as an error), but the code actually runs! :/

          QML is a JavaScript based language, so there is no real compilation, it is a interpreted language
          So yes, even if there are errors, as long as this part of code is not executed, all works fine.

          It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

          veryqtpersonV 1 Reply Last reply
          0
          • MarkkyboyM Offline
            MarkkyboyM Offline
            Markkyboy
            wrote on last edited by Markkyboy
            #5

            I commonly use Label and often set font size, weight, letterspacing, etc and I tend to write them in a compound fashion;

            Label {
                id: vidx
                text: "Hello Paul"
                color: "white"
                font {
                    bold: true
                    pixelSize: 72
                    letterSpacing: 2
                }
                anchors,fill: parent
            

            To use Label in QML, you will need to import QtQuick.Controls 2.12 or greater. Notably, Label inherits Text.

            Don't just sit there standing around, pick up a shovel and sweep up!

            I live by the sea, not in it.

            1 Reply Last reply
            0
            • KroMignonK KroMignon

              @paulpv said in Hello World "pixelSize is not a member of QFont" (similar w/ "family"):

              Odd that even though this gives a red warning (which I take as an error), but the code actually runs! :/

              QML is a JavaScript based language, so there is no real compilation, it is a interpreted language
              So yes, even if there are errors, as long as this part of code is not executed, all works fine.

              veryqtpersonV Offline
              veryqtpersonV Offline
              veryqtperson
              wrote on last edited by
              #6

              even if there are errors, as long as this part of code is not executed, all works fine

              Yet, one would expect a Qt-specific IDE such as Qt Creator not to have such errors when it doesn't know about documented properties of standard Qt/QML types.

              I had a similar issue with some of the ApplicationWindow properties in Qt 5.15.2:

              qml-window.png

              There are several bugs reported about similar problems (I think I was tracking QTBUG-85888), and the errors I was getting were resolved in later Qt versions, and as I understood this is an issue with Qt itself (*.qmltypes), not the Qt Creator.

              So what you can do is to upgrade to a newer Qt version, but sadly a newer one would be a 6.x (unless you are a commercial customer with access to revisions after 5.15.2, as it is an LTS release), and not everyone can upgrade to 6.x yet.

              KroMignonK 1 Reply Last reply
              0
              • veryqtpersonV veryqtperson

                even if there are errors, as long as this part of code is not executed, all works fine

                Yet, one would expect a Qt-specific IDE such as Qt Creator not to have such errors when it doesn't know about documented properties of standard Qt/QML types.

                I had a similar issue with some of the ApplicationWindow properties in Qt 5.15.2:

                qml-window.png

                There are several bugs reported about similar problems (I think I was tracking QTBUG-85888), and the errors I was getting were resolved in later Qt versions, and as I understood this is an issue with Qt itself (*.qmltypes), not the Qt Creator.

                So what you can do is to upgrade to a newer Qt version, but sadly a newer one would be a 6.x (unless you are a commercial customer with access to revisions after 5.15.2, as it is an LTS release), and not everyone can upgrade to 6.x yet.

                KroMignonK Offline
                KroMignonK Offline
                KroMignon
                wrote on last edited by
                #7

                @veryqtperson said in Hello World "pixelSize is not a member of QFont" (similar w/ "family"):

                Yet, one would expect a Qt-specific IDE such as Qt Creator not to have such errors when it doesn't know about documented properties of standard Qt/QML types.

                It depends on what kind of error you are talking about.
                Qt creator has nothing to do with JavaScript Engine used to run the QML code.
                What I said, is that even if you QML code is not totally correct, you can run it as long as you are not going through the wrong code part.
                This is the way JavaScript / interpreted languages works, so nothing direct link with Qt Creator.

                But, yes, Qt-Creator is far away from being bug free and the 'M16' error messages are very annoying

                It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                1 Reply Last reply
                1

                • Login

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