Unsolved A Vector of FontMetrics
-
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?
-
QVector<T>
requiresT
to be default-constructable due toQVector::reserve
. You can useQList<QFontMetrics>
instead -
-
@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?
-
@ofmrew
hi
VRonin explains here
https://forum.qt.io/topic/84222/qdatastream-serialze-deserialize-myclass-pointer/7 -
@mrjj Thanks. I think I understand the problem.
-
@ofmrew
Super
in case you want extra info
http://en.cppreference.com/w/cpp/concept/DefaultConstructible