summaryrefslogtreecommitdiff
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
commit2e8317af947d0e05395a38e198b6993e824f9037 (patch)
treebe8ba4a8cf1e87a4a7799e8967ef6c91904ca796
parentc8d1584638e3fcdb1a2926b6f7f97690cea1c0e8 (diff)
downloadqttools-6.2.tar.gz
Qt Designer: Fix the widget box tooltip display6.2
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();