本文整理汇总了C++中QThread::metaObject方法的典型用法代码示例。如果您正苦于以下问题:C++ QThread::metaObject方法的具体用法?C++ QThread::metaObject怎么用?C++ QThread::metaObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QThread
的用法示例。
在下文中一共展示了QThread::metaObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: check_parent_thread
// check the constructor's parent thread arguments
bool QObject::check_parent_thread(QObject *parent, QThreadData *parentThreadData, QThreadData *currentThreadData)
{
if (parent && parentThreadData != currentThreadData) {
QThread *parentThread = parentThreadData->thread;
QThread *currentThread = currentThreadData->thread;
qWarning("QObject:check_parent_thread() Can not create children for a parent in a different thread.\n"
"(Parent is %s(%p), parent's thread is %s(%p), current thread is %s(%p)",
parent->metaObject()->className(), parent,
parentThread ? parentThread->metaObject()->className() : "QThread",
parentThread, currentThread ? currentThread->metaObject()->className() : "QThread", currentThread);
return false;
}
return true;
}
示例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
}