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. invalid conversion from ‘int’ to ‘QFont::Weight’ [-fpermissive] 109 | font3.setWeight(750);
Qt 6.11 is out! See what's new in the release blog

invalid conversion from ‘int’ to ‘QFont::Weight’ [-fpermissive] 109 | font3.setWeight(750);

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

    Sorry but not understand ... In these day I convert My app from 5.15 to 6.7 ....

    QFont font1;
            font1.setPointSize(11);
            font1.setBold(true);
            font1.setWeight(750);
    

    but have these error ....

    invalid conversion from ‘int’ to ‘QFont::Weight’ [-fpermissive]   109 |         font3.setWeight(750);
    

    I understand can not use 0-87 value as in previous version ... but seems can use value from 100 to 900 .... so not understand. I try to use 750.0 so error become .... from 'double' ...

    bkt

    JonBJ 1 Reply Last reply
    0
    • gfxxG gfxx

      Sorry but not understand ... In these day I convert My app from 5.15 to 6.7 ....

      QFont font1;
              font1.setPointSize(11);
              font1.setBold(true);
              font1.setWeight(750);
      

      but have these error ....

      invalid conversion from ‘int’ to ‘QFont::Weight’ [-fpermissive]   109 |         font3.setWeight(750);
      

      I understand can not use 0-87 value as in previous version ... but seems can use value from 100 to 900 .... so not understand. I try to use 750.0 so error become .... from 'double' ...

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #3

      @gfxx
      Be aware that as per @Christian-Ehrlicher's new enumerated values you are not supposed to set it to exactly the 750 you used to have. That number would now lie between QFont::Bold and QFont::ExtraBold. I presume this is acceptable. If you really want specifically 750 you would presumably have to write font1.setWeight(static_cast<QFont::Weight>(750)) now.

      1 Reply Last reply
      1
      • Christian EhrlicherC Online
        Christian EhrlicherC Online
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #2

        As you can see in the documentation setWeight() now takes an enum instead an integer - so change your code accordingly.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        2
        • gfxxG gfxx

          Sorry but not understand ... In these day I convert My app from 5.15 to 6.7 ....

          QFont font1;
                  font1.setPointSize(11);
                  font1.setBold(true);
                  font1.setWeight(750);
          

          but have these error ....

          invalid conversion from ‘int’ to ‘QFont::Weight’ [-fpermissive]   109 |         font3.setWeight(750);
          

          I understand can not use 0-87 value as in previous version ... but seems can use value from 100 to 900 .... so not understand. I try to use 750.0 so error become .... from 'double' ...

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #3

          @gfxx
          Be aware that as per @Christian-Ehrlicher's new enumerated values you are not supposed to set it to exactly the 750 you used to have. That number would now lie between QFont::Bold and QFont::ExtraBold. I presume this is acceptable. If you really want specifically 750 you would presumably have to write font1.setWeight(static_cast<QFont::Weight>(750)) now.

          1 Reply Last reply
          1
          • gfxxG Offline
            gfxxG Offline
            gfxx
            wrote on last edited by
            #4

            real sorry .... see these morning "enum QFont::weight" .... so understand.

            thanks to all

            bkt

            1 Reply Last reply
            0
            • gfxxG gfxx has marked this topic as solved on

            • Login

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