Mercurial > minori
comparison include/gui/widgets/graph.h @ 273:f31305b9f60a
*: various code safety changes
this also makes the code build on Qt 5.7. I can't test it though
because I don't have it working... FAIL!
| author | Paper <paper@paper.us.eu.org> |
|---|---|
| date | Thu, 18 Apr 2024 16:53:17 -0400 |
| parents | 3ec7804abf17 |
| children | f81bed4e04ac |
comparison
equal
deleted
inserted
replaced
| 272:5437009cb10e | 273:f31305b9f60a |
|---|---|
| 54 inline unsigned long GetTextWidth() { | 54 inline unsigned long GetTextWidth() { |
| 55 unsigned long ret = 0; | 55 unsigned long ret = 0; |
| 56 QFontMetrics metric(font()); | 56 QFontMetrics metric(font()); |
| 57 | 57 |
| 58 for (const auto& item : map) { | 58 for (const auto& item : map) { |
| 59 unsigned long width = metric.horizontalAdvance(QString::number(item.first), -1); | 59 unsigned long width = metric.boundingRect(QString::number(item.first)).width(); |
| 60 if (width > ret) | 60 if (width > ret) |
| 61 ret = width; | 61 ret = width; |
| 62 } | 62 } |
| 63 | 63 |
| 64 return ret; | 64 return ret; |
| 67 inline unsigned long GetValueWidth() { | 67 inline unsigned long GetValueWidth() { |
| 68 unsigned long ret = 0; | 68 unsigned long ret = 0; |
| 69 QFontMetrics metric(font()); | 69 QFontMetrics metric(font()); |
| 70 | 70 |
| 71 for (const auto& item : map) { | 71 for (const auto& item : map) { |
| 72 unsigned long width = metric.horizontalAdvance(QString::number(item.second), -1); | 72 unsigned long width = metric.boundingRect(QString::number(item.second)).width(); |
| 73 if (width > ret) | 73 if (width > ret) |
| 74 ret = width; | 74 ret = width; |
| 75 } | 75 } |
| 76 | 76 |
| 77 return ret; | 77 return ret; |
