| 26 | |
| 27 | |
| 28 | ButtonDelegate::ButtonDelegate(QObject *parent, QString text) |
| 29 | : QItemDelegate(parent) |
| 30 | { |
| 31 | QFont font; |
| 32 | |
| 33 | font.setFamily(font.defaultFamily()); |
| 34 | |
| 35 | QFontMetrics fm(font); |
| 36 | |
| 37 | this->text = text; |
| 38 | #if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) |
| 39 | this->buttonWidth = fm.horizontalAdvance(" " + text + " "); |
| 40 | #else |
| 41 | this->buttonWidth = fm.width(" " + text + " "); |
| 42 | #endif // QT_VERSION_CHECK |
| 43 | } |
| 44 | |
| 45 | |
| 46 | void |