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. A Vector of FontMetrics
QtWS25 Last Chance

A Vector of FontMetrics

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 1.4k 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.
  • O Offline
    O Offline
    ofmrew
    wrote on last edited by
    #1

    I have in the .h

    QFont font0{"Times", 20};
    QFont font1{"Times", 15};
    QFont font2{"Times", 11};
    QFont font3{"Times", 8};
    QFontMetrics fm0{font0};
    QFontMetrics fm1{font1};
    QFontMetrics fm2{font2};
    QFontMetrics fm3{font3};
    QVector<eqnlist> list;
    QVector<QFont> vfonts;
    QVector<QFontMetrics> vfm;
    

    And in the .cpp

    vfonts.append(font0);
    vfonts.append(font1);
    vfonts.append(font2);
    vfonts.append(font3);
    vfm.append(fm0);

    The creation of the vector of fonts works, but the vector of fontmetrics get a compilation error at line 320 in vector.h. No matching QFontMetrics::QFontMetrics. (This would be simpler if I could copy the error message.)

    I know I must be doing something stupid, but I do not see it?

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      QVector<T> requires T to be default-constructable due to QVector::reserve. You can use QList<QFontMetrics> instead

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      2
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @ofmrew said in A Vector of FontMetrics:

        This would be simpler if I could copy the error message.)

        alt text

        O 1 Reply Last reply
        1
        • mrjjM mrjj

          @ofmrew said in A Vector of FontMetrics:

          This would be simpler if I could copy the error message.)

          alt text

          O Offline
          O Offline
          ofmrew
          wrote on last edited by
          #4

          @mrjj Thanks. I am just use to using the mouse to select and then copy. Using the List versus the Vector will not be a problem, but my question is why is QVector different and why does QList not have the same restrictions?

          mrjjM 1 Reply Last reply
          0
          • O ofmrew

            @mrjj Thanks. I am just use to using the mouse to select and then copy. Using the List versus the Vector will not be a problem, but my question is why is QVector different and why does QList not have the same restrictions?

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @ofmrew
            hi
            VRonin explains here
            https://forum.qt.io/topic/84222/qdatastream-serialze-deserialize-myclass-pointer/7

            O 1 Reply Last reply
            1
            • mrjjM mrjj

              @ofmrew
              hi
              VRonin explains here
              https://forum.qt.io/topic/84222/qdatastream-serialze-deserialize-myclass-pointer/7

              O Offline
              O Offline
              ofmrew
              wrote on last edited by
              #6

              @mrjj Thanks. I think I understand the problem.

              mrjjM 1 Reply Last reply
              0
              • O ofmrew

                @mrjj Thanks. I think I understand the problem.

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @ofmrew
                Super
                in case you want extra info
                http://en.cppreference.com/w/cpp/concept/DefaultConstructible

                1 Reply Last reply
                2

                • Login

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