summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2022-03-25 14:05:49 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-04-06 11:57:37 +0000
commit9a856489aa687f8056076bd3abb876b8e5205e61 (patch)
treecfd5c220d587453a94bd839a5a307fe95dded48f
parentab4d63662141fef210037ce139a1dc867dd72ef2 (diff)
Qt Designer: Fix the widget box tooltip display
The widget box code looked the widgets up in the database by the widget box name which is usually a text like "Line Edit". Rearrange the code to search by class name. Task-number: QTBUG-102028 Change-Id: Iabfddd14d49344ef850aaceefee3c53e95adafb2 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> (cherry picked from commit f3131ec7e7a6bd451706155e349306247b0e70c9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp b/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp
index 2f5b7f536..65a697a5e 100644
--- a/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp
+++ b/src/designer/src/components/widgetbox/widgetboxcategorylistview.cpp
@@ -200,21 +200,21 @@ bool WidgetBoxCategoryModel::removeCustomWidgets()
void WidgetBoxCategoryModel::addWidget(const QDesignerWidgetBoxInterface::Widget &widget, const QIcon &icon,bool editable)
{
- // build item. Filter on name + class name if it is different and not a layout.
+ static const QRegularExpression classNameRegExp(QStringLiteral("<widget +class *= *\"([^\"]+)\""));
+ Q_ASSERT(classNameRegExp.isValid());
+ const auto match = classNameRegExp.match(widget.domXml());
+ const QString className = match.hasMatch() ? match.captured(1) : QString{};
+
+ // Filter on name + class name if it is different and not a layout.
QString filter = widget.name();
- if (!filter.contains(QStringLiteral("Layout"))) {
- static const QRegularExpression classNameRegExp(QStringLiteral("<widget +class *= *\"([^\"]+)\""));
- Q_ASSERT(classNameRegExp.isValid());
- const QRegularExpressionMatch match = classNameRegExp.match(widget.domXml());
- if (match.hasMatch()) {
- const QString className = match.captured(1);
- if (!filter.contains(className))
- filter += className;
- }
- }
+ if (!className.isEmpty() && !filter.contains(QStringLiteral("Layout")) && !filter.contains(className))
+ filter += className;
+
WidgetBoxCategoryEntry item(widget, filter, icon, editable);
const QDesignerWidgetDataBaseInterface *db = m_core->widgetDataBase();
- const int dbIndex = db->indexOfClassName(widget.name());
+ int dbIndex = className.isEmpty() ? -1 : db->indexOfClassName(className);
+ if (dbIndex == -1)
+ dbIndex = db->indexOfClassName(widget.name());
if (dbIndex != -1) {
const QDesignerWidgetDataBaseItemInterface *dbItem = db->item(dbIndex);
const QString toolTip = dbItem->toolTip();