270 @param parent reference to the parent object (QObject) |
270 @param parent reference to the parent object (QObject) |
271 @return reference to the created action (QAction) |
271 @return reference to the created action (QAction) |
272 """ |
272 """ |
273 fm = QFontMetrics(self.font()) |
273 fm = QFontMetrics(self.font()) |
274 if self.__maxWidth == -1: |
274 if self.__maxWidth == -1: |
275 try: |
275 self.__maxWidth = fm.horizontalAdvance("m") * 30 |
276 self.__maxWidth = fm.horizontalAdvance("m") * 30 |
|
277 except AttributeError: |
|
278 self.__maxWidth = fm.width("m") * 30 |
|
279 smallText = fm.elidedText(text, Qt.TextElideMode.ElideMiddle, self.__maxWidth) |
276 smallText = fm.elidedText(text, Qt.TextElideMode.ElideMiddle, self.__maxWidth) |
280 |
277 |
281 return QAction(icon, smallText, parent) |
278 return QAction(icon, smallText, parent) |
282 |
279 |
283 def __actionTriggered(self, action): |
280 def __actionTriggered(self, action): |