14 #include <QApplication>
15 #include <QTreeWidget>
42 auto fnFindObject = [&]() -> T*
44 for (
auto pWidget: qApp->topLevelWidgets())
46 if (
auto pFound = qobject_cast<T*>(pWidget))
48 if (strObjectName.isEmpty() || strObjectName == pFound->objectName())
54 if (
auto pFound = pWidget->findChild<T*>(strObjectName))
65 if (QThread::currentThread() == qApp->thread())
67 pObject = fnFindObject();
71 QMetaObject::invokeMethod(qApp, fnFindObject, Qt::BlockingQueuedConnection, &pObject);
77 "No widget with name %s and type %s.",
78 strObjectName.toLocal8Bit().data(),
79 T::staticMetaObject.className());
92 QString
dump_tree(
const QTreeWidgetItem* pNode,
size_t nColumnCount, QString strPrefix =
"");
100 QString
dump_tree(
const QTreeWidget* pTree,
size_t nColumnCount);
159 QAction*
find_action(QMenu* pMenu,
const QString& strName,
bool bThrow =
true);
166 void trigger_action(QAction* pAction, Qt::ConnectionType eConnectionType = Qt::BlockingQueuedConnection);
173 void trigger_action(
const QString& strActionObjectName, Qt::ConnectionType eConnectionType = Qt::BlockingQueuedConnection);
187 QString dump_tree(
const QAbstractItemModel* pTree,
size_t nColumnCount,
const QModelIndex oNode = QModelIndex(), QString strPrefix =
"");
196 using mega::wait_for_next_idle;
197 using mega::find_action;
198 using mega::trigger_action;
199 using nitro::dump_tree;
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
A common result class usable as return value throughout.
std::chrono::nanoseconds nanoseconds
Compatibility to C++11 std::chrono::nanoseconds
std::chrono::milliseconds milliseconds
Compatibility to C++11 std::chrono::milliseconds
QString dump_tree(const QTreeWidgetItem *pNode, size_t nColumnCount, QString strPrefix="")
Dumps the content of a QTreeWidgetItem.
T * find_qobject(const QString &strObjectName)
Utility that finds a widget/object by its object name.
tResult wait_for_next_ui_timer(std::chrono::nanoseconds tmTimeout=std::chrono::nanoseconds{-1})
Wait until at least one more OnTimer() call have been issued by the X system.
tResult compare_dump(const QString &strChecked, const QString &strExpected)
Compare to large strings.
void schedule_in_gui_thread(std::function< void()> fnFunction)
Schedules the given function to be executed from within the GUI thread some time in the future.
tResult execute_in_gui_thread(std::function< tResult()> fnFunction, std::chrono::milliseconds tmTimeout=std::chrono::milliseconds{0})
Execute the given function from within the GUI thread and wait until it has finished.
Namespace for entire ADTF SDK.
#define THROW_ERROR_DESC(_code,...)
throws a tResult exception