Call stack: 0 QApplication::topLevelWidgets qapplication.cpp 1762 0x642dfa1e 1 QWindowsXPStylePrivate::winId qwindowsxpstyle.cpp 387 0x64400cd2 2 XPThemeData::handle qwindowsxpstyle.cpp 203 0x644006a0 3 XPThemeData::isValid qwindowsxpstyle.cpp 188 0x6440078b 4 QWindowsVistaStyle::drawPrimitive qwindowsvistastyle.cpp 403 0x643e526b 5 QProxyStyle::drawPrimitive qproxystyle.cpp 191 0x643a97ea 6 QStyleSheetStyle::drawPrimitive qstylesheetstyle.cpp 4350 0x643b27ed 7 QTreeView::drawBranches qtreeview.cpp 1888 0x64648878 8 QTreeView::drawRow qtreeview.cpp 1755 0x64647ebb 9 QTreeView::drawTree qtreeview.cpp 1501 0x646473eb ======================================================================================================== QWindowsVistaStyle::drawPrimitive qwindowsvistastyle.cpp 403: case PE_IndicatorBranch: { XPThemeData theme(0, painter, QWindowsXPStylePrivate::TreeViewTheme); static int decoration_size = 0; if (d->initTreeViewTheming() && theme.isValid() && !decoration_size) { ======================================================================================================== XPThemeData::isValid qwindowsxpstyle.cpp 188: return QWindowsXPStylePrivate::useXP() && theme >= 0 && handle() ======================================================================================================== XPThemeData::handle qwindowsxpstyle.cpp 203 htheme = QWindowsXPStylePrivate::createTheme(theme, QWindowsXPStylePrivate::winId(widget)); ======================================================================================================== QWindowsXPStylePrivate::winId qwindowsxpstyle.cpp 387 if (widget) if (const HWND hwnd = QApplicationPrivate::getHWNDForWidget(const_cast(widget))) return hwnd; foreach (const QWidget *toplevel, QApplication::topLevelWidgets()) ======================================================================================================== QApplication::topLevelWidgets qapplication.cpp 1762 QWidgetList all = allWidgets(); for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) { QWidget *w = *it; if (w->isWindow() && w->windowType() != Qt::Desktop) list.append(w); } ======================================================================================================== Description: drawPrimitive creates an instance of XPThemeData and then calls theme.isValid. isValid calls handle. handle calls winID. winID calls topLevelWidgets because parameter widget is 0. Parameter widget is 0 because instance of XPThemeData was created with 0. topLevelWidgets calls allWidgets and then iterates through all widgets. Because we have more than 16000 widgets in our application topLevelWidgets takes many time. For that reason painting of a branch in a QTreeView takes a lot of time, more than 0.4s.