本文整理汇总了C++中QThread::objectName方法的典型用法代码示例。如果您正苦于以下问题:C++ QThread::objectName方法的具体用法?C++ QThread::objectName怎么用?C++ QThread::objectName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QThread
的用法示例。
在下文中一共展示了QThread::objectName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: thread
QcepObject::~QcepObject()
{
#ifndef QT_NO_DEBUG
QThread *currTh = QThread::currentThread();
QThread *objTh = thread();
if (objTh && currTh != objTh) {
printf("Deleting object from different thread %s (%s, %s)\n",
qPrintable(objectName()),
qPrintable(currTh ? currTh->objectName() : "null"),
qPrintable(objTh ? objTh->objectName() : "null"));
}
#endif
s_ObjectDeleteCount.fetchAndAddOrdered(1);
#ifndef QT_NO_DEBUG
s_Allocated.remove(this);
#endif
}
示例2: toSetThreadName
void toSetThreadName(QThread const& p)
{
// This was copied from QT trunk - as of 4.8.2 it is not used yet
QByteArray objectName = p.objectName().toLatin1();
if (objectName.isEmpty())
objectName = p.metaObject()->className();
#if defined(__linux__)
prctl(PR_SET_NAME, (unsigned long)objectName.constData(), 0, 0, 0);
#elif defined(Q_OS_MAC)
pthread_setname_np(objectName.constData());
#endif
}
示例3: reportException
void Application::reportException(QString text)
{
QThread* main = this->thread();
QThread* current = QThread::currentThread();
QString threadName = current->objectName();
if (threadName.isEmpty())
{
if (main==current)
threadName = "MAIN";
else
threadName = "SECONDARY";
}
reportError(QString("Exception caught: [%1]\nin thread [%2]").arg(text).arg(threadName));
}