本文整理汇总了C++中QObject::objectName方法的典型用法代码示例。如果您正苦于以下问题:C++ QObject::objectName方法的具体用法?C++ QObject::objectName怎么用?C++ QObject::objectName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QObject
的用法示例。
在下文中一共展示了QObject::objectName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setTopLevelObjects
void QuickInterpreter::setTopLevelObjects(QObjectList *l)
{
QSEngine::init();
if(toplevel)
for (int i=0; i<toplevel->size(); ++i) {
QObject *o = toplevel->at(i);
disconnect(o, SIGNAL(destroyed(QObject*)),
this, SLOT(topLevelDestroyed(QObject*)));
}
delete toplevel;
toplevel = new QObjectList;
kids.clear();
if (!l) {
toplevel->clear();
return;
}
QSObject global(env()->globalObject());
for (int i=0; i<toplevel->size(); ++i) {
QObject *o = toplevel->at(i);
if (hasTopLevelParent(o)) {
continue;
}
kids.append(o->objectName());
connect(o, SIGNAL(destroyed(QObject *)),
this, SLOT(topLevelDestroyed(QObject *)));
global.put(o->objectName(), wrap(o));
staticGlobals << o->objectName();
toplevel->append(o);
}
delete l;
}
示例2: if
static QObject *qChildHelper(const char *objName, const char *inheritsClass,
bool recursiveSearch, const QObjectList &children)
{
if (children.isEmpty())
return 0;
bool onlyWidgets = (inheritsClass
&& qstrcmp(inheritsClass, "QWidget") == 0);
const QLatin1String oName(objName);
for (int i = 0; i < children.size(); ++i)
{
QObject *obj = children.at(i);
if (onlyWidgets)
{
if (obj->isWidgetType() && (!objName || obj->objectName() == oName))
return obj;
}
else if ((!inheritsClass || obj->inherits(inheritsClass))
&& (!objName || obj->objectName() == oName))
return obj;
if (recursiveSearch && (dynamic_cast<MythUIGroup *>(obj) != NULL)
&& (obj = qChildHelper(objName, inheritsClass,
recursiveSearch,
obj->children())))
return obj;
}
return 0;
}
示例3: setAttribute
void Object::setAttribute()
{
IObject::setAttribute();
QObject* widget = sender();
if(widget->objectName() == "experience")
_experience = ((QSpinBox*)widget)->value();
else if(widget->objectName() == "cooldown")
_cooldown = ((QSpinBox*)widget)->value();
}
示例4: callQTModule
void WinControl::callQTModule( )
{
QObject *obj = (QObject *)sender();
if(string("*exit*") == obj->objectName().toAscii().data()) SYS->stop();
else
{
try{ callQTModule(obj->objectName().toAscii().data()); }
catch(TError err) { }
}
}
示例5: callClient
void ClientBackgroundManager::callClient() {
QObject* sendedFrom = sender();
qDebug() << "Called callClient" << sendedFrom->objectName();
//send message to server
MessageEnvelop call(REQUEST_CALL_TO_CLIENT_FROM_SERVER);
call.setName(sendedFrom->objectName());
emit sendDataToServer(call);
//myClient2ServerThread.sendMessageToServer(call);
//GUI
}
示例6: setForwardRescheduleSignal
void Courier::setForwardRescheduleSignal(QObject &ob, bool fwd)
{
if(fwd) {
if(!connect(&ob,SIGNAL(reschedule(quint64)),this,SIGNAL(reschedule(quint64)),OC_CONTYPE)) {
qWarning()<<"ERROR: Could not connect "<<ob.objectName();
}
} else {
if(!disconnect(&ob,SIGNAL(reschedule(quint64)),this,SIGNAL(reschedule(quint64)))) {
qWarning()<<"ERROR: Could not disconnect "<<ob.objectName();
}
}
}
示例7: init
void qt_object_node::init(QObject& obj)
{
auto name = obj.objectName();
if (!name.isEmpty())
set_name(obj.objectName().toStdString());
else
{
std::string str;
const QMetaObject* mo = obj.metaObject();
while (str.empty())
{
str = mo->className();
mo = mo->superClass();
if (!mo)
break;
}
if (!str.empty())
{
set_name(std::move(str));
}
else
{
set_name("Object");
}
}
// Note : we create the childrens, and then lock the vector
// because the children creation operation calls node_base::children() which
// causes
// double locking.
decltype(m_children) children_vect;
for (auto c : obj.children())
{
children_vect.push_back(
std::make_unique<qt_object_node>(*c, m_device, *this));
}
for (int i = 0; i < obj.metaObject()->propertyCount(); i++)
{
children_vect.push_back(std::make_unique<qt_property_node>(
obj, obj.metaObject()->property(i), m_device, *this));
}
{
write_lock_t lock{m_mutex};
std::move(
children_vect.begin(), children_vect.end(),
std::back_inserter(m_children));
}
}
示例8: sender
void GUI::EverywhereWindow::switchView() {
QObject* senderObj = sender();
ui->globalWidget->setStyleSheet("QWidget#globalWidget { background : url(C:/everywhere/images/"
+ _menuWidgets[senderObj->objectName()].first + "Background.png); }");
ui->globalWidget->style()->unpolish(ui->globalWidget);
ui->globalWidget->style()->polish(ui->globalWidget);
ui->globalWidget->update();
_current = _menuWidgets[senderObj->objectName()];
manageMenu();
_current.second->initialize();
QTimer::singleShot(400, this, SLOT(updateView()));
}
示例9: buttonClickedSlot
void Combat::buttonClickedSlot()
{
if(!rollDice)
{
//we can apply the hit now
for(int i = 0; i < playerCount.size(); i++)
{
if(getPlayerTurn() == playerCount.at(i))
{
int hitPoint = playerHitPoint.at(i)->objectName().toInt();
//get the button
QObject *button = sender();
QWidget *widget = qobject_cast<QWidget *>(button);
//get the player rack
QObject *PlayerRack = button->parent();
int playerWidgetID = PlayerRack->objectName().toInt();
if(playerWidgetID == getPlayerTurn())
{
Message("Warning", "You can't remove your things");
} else {
//remove the thing and button
if(hitPoint == 0)
{
//not enough hitpoint,change to next player
popMessageBox();
Message("Warning", "Don't have hitpoint!");
break;
} else {
//remove the things
int ThingID = button->objectName().toInt();
removePlayerThingFromID(ThingID);
//delete the button
delete widget;
//refresh the playerhitpoint label
playerHitPoint.at(i)->setObjectName(QString::number(hitPoint-1));
QString temp ="Player " + QString::number(playerCount.at(i)) + " HitPoint : " + playerHitPoint.at(i)->objectName();
playerHitPoint.at(i)->setText(temp);
//check if the hitPoint become to 0
if(!checkAllPlayerRack()&&(hitPoint == 1))
{
popMessageBox();
break;
}
}
}
}
}
}
}
示例10: format_arg
void format_arg(fmt::BasicFormatter<char>& f, const char*&, const QObject& qobj)
{
auto& w = f.writer();
w.write("{}<{:#x}", qobj.metaObject()->className(), reinterpret_cast<uintptr_t>(&qobj));
if (!qobj.objectName().isEmpty())
{
w.write(" ");
w.write(qobj.objectName().toStdString());
}
w.write(">");
}
示例11: findChildren
int PythonQtStdDecorators::findChildren(QObject* parent, const char* typeName, const QMetaObject* meta, const QRegExp& regExp, QList<QObject*>& list)
{
const QObjectList& children = parent->children();
int i;
for (i = 0; i < children.size(); ++i) {
QObject* obj = children.at(i);
if (!obj)
return -1;
// Skip if the name doesn't match.
if (regExp.indexIn(obj->objectName()) == -1)
continue;
if ((typeName && obj->inherits(typeName)) ||
(meta && meta->cast(obj))) {
list += obj;
}
if (findChildren(obj, typeName, meta, regExp, list) < 0)
return -1;
}
return 0;
}
示例12: findChild
QObject* PythonQtStdDecorators::findChild(QObject* parent, const char* typeName, const QMetaObject* meta, const QString& name)
{
const QObjectList &children = parent->children();
int i;
for (i = 0; i < children.size(); ++i) {
QObject* obj = children.at(i);
if (!obj)
return NULL;
// Skip if the name doesn't match.
if (!name.isNull() && obj->objectName() != name)
continue;
if ((typeName && obj->inherits(typeName)) ||
(meta && meta->cast(obj)))
return obj;
}
for (i = 0; i < children.size(); ++i) {
QObject* obj = findChild(children.at(i), typeName, meta, name);
if (obj != NULL)
return obj;
}
return NULL;
}
示例13: itemSelected
void RibbonWidget::itemSelected()
{
QObject *source = this->sender();
QString name = source->objectName();
emit itemSelected(name);
}
示例14: componentComplete
void MyMenu::componentComplete()
{
QObjectList temp_list = children ();
for (int i=0; i<temp_list.count (); ++i) {
QObject *obj = temp_list.at (i);
if( obj->objectName ()=="MyMenuItem"){
MyMenuItem *item = qobject_cast<MyMenuItem*>(obj);
menu->addAction(item);
}else if(obj->objectName ()=="MenuSeparator"){
menu->addSeparator ();
}else if(obj->objectName ()=="MyMenu"){
MyMenu *item = qobject_cast<MyMenu*>(obj);
menu->addMenu (item->menu);
}
}
}
示例15: contactClick
void Home::contactClick()
{
QObject *senderObj = sender();
QString senderObjName = senderObj->objectName();
QPushButton *tmp = (QPushButton *)senderObj;
if (_pushtmp != NULL)
{
_pushtmp->setEnabled(true);
//_pushtmp->setStyleSheet("QPushButton{color: rgb(0, 0, 0);}");
}
tmp->setEnabled(false);
_pushtmp = tmp;
_activeUser = senderObjName.toInt();
if (_activeUser == _myid)
{
ui->_lineContactName->setReadOnly(false);
ui->_lineSurnameEdit->setReadOnly(false);
ui->_lineBirthday->setReadOnly(false);
ui->_lineLocalisation->setReadOnly(false);
ui->_linePhoneNumber->setReadOnly(false);
}
else
{
ui->_lineContactName->setReadOnly(true);
ui->_lineSurnameEdit->setReadOnly(true);
ui->_lineBirthday->setReadOnly(true);
ui->_lineLocalisation->setReadOnly(true);
ui->_linePhoneNumber->setReadOnly(true);
}
ui->_lineContactName->setText(_musers[_activeUser]->get_name().c_str());
ui->_lineSurnameEdit->setText(_musers[_activeUser]->get_surname().c_str());
ui->_lineBirthday->setText(_musers[_activeUser]->get_birth().c_str());
ui->_lineLocalisation->setText(_musers[_activeUser]->get_address().c_str());
ui->_linePhoneNumber->setText(_musers[_activeUser]->get_phone().c_str());
}