本文整理汇总了C++中Q_ARG函数的典型用法代码示例。如果您正苦于以下问题:C++ Q_ARG函数的具体用法?C++ Q_ARG怎么用?C++ Q_ARG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Q_ARG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QmlBridge_SendToGo
char* QmlBridge_SendToGo(void* ptr, char* data)
{
QString returnArg;
QMetaObject::invokeMethod(static_cast<QmlBridge*>(ptr), "sendToGo", Q_RETURN_ARG(QString, returnArg), Q_ARG(QString, QString(data)));
return returnArg.toUtf8().data();
}
示例2: Q_ARG
void ZealDocsetsRegistry::runQuery(const QString& query)
{
lastQuery += 1;
QMetaObject::invokeMethod(this, "_runQuery", Qt::QueuedConnection, Q_ARG(QString, query), Q_ARG(int, lastQuery));
}
示例3: setTitle
void setTitle(const QString &title)
{
const auto text = QString("<b>%1</b>").arg(title.toHtmlEscaped());
//cannot call setText in calling thread, forward to the label slot
QMetaObject::invokeMethod(_label, "setText", Qt::QueuedConnection, Q_ARG(QString, text));
}
示例4: dispatch
void dispatch(QString type, QJSValue message) {
for (int i = 0 ; i < 3;i++) {
QMetaObject::invokeMethod(this,"dispatched",Q_ARG(QString, type), Q_ARG(QJSValue, message));
}
}
示例5: write
void write(const QVariant &vrequest)
{
ZhttpRequestPacket request;
if(!request.fromVariant(vrequest))
{
QVariantHash vhash = vrequest.toHash();
if(vhash["type"].toByteArray() != "cancel")
{
QMetaObject::invokeMethod(this, "respondError", Qt::QueuedConnection, Q_ARG(QByteArray, "bad-request"));
}
else
{
cleanup();
QMetaObject::invokeMethod(q, "finished", Qt::QueuedConnection);
}
return;
}
// cancel session if a wrong sequenced packet is received
if(inSeq == -1 || request.seq == -1 || request.seq != inSeq + 1)
{
if(request.type != ZhttpRequestPacket::Cancel)
{
QMetaObject::invokeMethod(this, "respondCancel", Qt::QueuedConnection);
}
else
{
cleanup();
QMetaObject::invokeMethod(q, "finished", Qt::QueuedConnection);
}
return;
}
if(request.type == ZhttpRequestPacket::Cancel)
{
cleanup();
QMetaObject::invokeMethod(q, "finished", Qt::QueuedConnection);
return;
}
inSeq = request.seq;
refreshTimeout();
// all we care about from follow-up writes are body and credits
if(request.credits != -1)
outCredits += request.credits;
if(transport == HttpTransport)
{
if(request.type == ZhttpRequestPacket::Data)
{
if(bodySent)
{
QMetaObject::invokeMethod(this, "respondError", Qt::QueuedConnection, Q_ARG(QByteArray, "bad-request"));
return;
}
refreshActivityTimeout();
if(!request.body.isEmpty())
hreq->writeBody(request.body);
// the 'more' flag only has significance if body field present
if(!request.more)
{
bodySent = true;
hreq->endBody();
}
}
}
else // WebSocketTransport
{
if(request.type == ZhttpRequestPacket::Data || request.type == ZhttpRequestPacket::Close || request.type == ZhttpRequestPacket::Ping || request.type == ZhttpRequestPacket::Pong)
{
refreshActivityTimeout();
if(request.type == ZhttpRequestPacket::Data)
{
WebSocket::Frame::Type ftype;
if(wsSendingMessage)
ftype = WebSocket::Frame::Continuation;
else if(request.contentType == "binary")
ftype = WebSocket::Frame::Binary;
else
ftype = WebSocket::Frame::Text;
wsSendingMessage = request.more;
wsPendingWrites += request.body.size();
ws->writeFrame(WebSocket::Frame(ftype, request.body, request.more));
}
else if(request.type == ZhttpRequestPacket::Ping)
{
wsPendingWrites += 0;
ws->writeFrame(WebSocket::Frame(WebSocket::Frame::Ping, QByteArray(), false));
}
//.........这里部分代码省略.........
示例6: Q_ARG
Q_ARG(int, status));
}
static void NotifyTransactionChanged(WalletModel *walletmodel, CWallet *wallet, const uint256 &hash, ChangeType status)
{
Q_UNUSED(wallet);
Q_UNUSED(hash);
Q_UNUSED(status);
QMetaObject::invokeMethod(walletmodel, "updateTransaction", Qt::QueuedConnection);
}
static void ShowProgress(WalletModel *walletmodel, const std::string &title, int nProgress)
{
// emits signal "showProgress"
QMetaObject::invokeMethod(walletmodel, "showProgress", Qt::QueuedConnection,
Q_ARG(QString, QString::fromStdString(title)),
Q_ARG(int, nProgress));
}
static void NotifyWatchonlyChanged(WalletModel *walletmodel, bool fHaveWatchonly)
{
QMetaObject::invokeMethod(walletmodel, "updateWatchOnlyFlag", Qt::QueuedConnection,
Q_ARG(bool, fHaveWatchonly));
}
void WalletModel::subscribeToCoreSignals()
{
// Connect signals to wallet
wallet->NotifyStatusChanged.connect(boost::bind(&NotifyKeyStoreStatusChanged, this, _1));
wallet->NotifyAddressBookChanged.connect(boost::bind(NotifyAddressBookChanged, this, _1, _2, _3, _4, _5, _6));
wallet->NotifyTransactionChanged.connect(boost::bind(NotifyTransactionChanged, this, _1, _2, _3));
示例7: Q_ARG
void EAPDaemonAdapter::Login(const QVariantMap &userinfo)
{
// handle method call com.qh3client.EAPDaemon.Login
QMetaObject::invokeMethod(parent(), "Login", Q_ARG(QVariantMap, userinfo));
}
示例8: main
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
app.setOrganizationName("Cockatrice");
app.setApplicationName("Servatrice");
QStringList args = app.arguments();
bool testRandom = args.contains("--test-random");
bool testHashFunction = args.contains("--test-hash");
bool logToConsole = args.contains("--log-to-console");
QString configPath;
int hasConfigPath=args.indexOf("--config");
if(hasConfigPath > -1 && args.count() > hasConfigPath + 1)
configPath = args.at(hasConfigPath + 1);
qRegisterMetaType<QList<int> >("QList<int>");
#if QT_VERSION < 0x050000
// gone in Qt5, all source files _MUST_ be utf8-encoded
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
#endif
configPath = SettingsCache::guessConfigurationPath(configPath);
qWarning() << "Using configuration file: " << configPath;
settingsCache = new SettingsCache(configPath);
loggerThread = new QThread;
loggerThread->setObjectName("logger");
logger = new ServerLogger(logToConsole);
logger->moveToThread(loggerThread);
loggerThread->start();
QMetaObject::invokeMethod(logger, "startLog", Qt::BlockingQueuedConnection, Q_ARG(QString, settingsCache->value("server/logfile", QString("server.log")).toString()));
#if QT_VERSION < 0x050000
if (logToConsole)
qInstallMsgHandler(myMessageOutput);
else
qInstallMsgHandler(myMessageOutput2);
#else
if (logToConsole)
qInstallMessageHandler(myMessageOutput);
else
qInstallMessageHandler(myMessageOutput2);
#endif
#ifdef Q_OS_UNIX
struct sigaction hup;
hup.sa_handler = ServerLogger::hupSignalHandler;
sigemptyset(&hup.sa_mask);
hup.sa_flags = 0;
hup.sa_flags |= SA_RESTART;
sigaction(SIGHUP, &hup, 0);
struct sigaction segv;
segv.sa_handler = sigSegvHandler;
segv.sa_flags = SA_RESETHAND;
sigemptyset(&segv.sa_mask);
sigaction(SIGSEGV, &segv, 0);
sigaction(SIGABRT, &segv, 0);
signal(SIGPIPE, SIG_IGN);
#endif
rng = new RNG_SFMT;
std::cerr << "Servatrice " << VERSION_STRING << " starting." << std::endl;
std::cerr << "-------------------------" << std::endl;
PasswordHasher::initialize();
if (testRandom)
testRNG();
if (testHashFunction)
testHash();
Servatrice *server = new Servatrice();
QObject::connect(server, SIGNAL(destroyed()), &app, SLOT(quit()), Qt::QueuedConnection);
int retval = 0;
if (server->initServer()) {
std::cerr << "-------------------------" << std::endl;
std::cerr << "Server initialized." << std::endl;
#if QT_VERSION < 0x050000
qInstallMsgHandler(myMessageOutput);
#else
qInstallMessageHandler(myMessageOutput);
#endif
retval = app.exec();
std::cerr << "Server quit." << std::endl;
std::cerr << "-------------------------" << std::endl;
}
delete rng;
delete settingsCache;
logger->deleteLater();
loggerThread->wait();
delete loggerThread;
//.........这里部分代码省略.........
示例9: Q_ARG
// Asynchronously load the new scene given by sceneName
void SceneManager::setScene( const char* sceneName )
{
QMetaObject::invokeMethod(this, "onLoadNewScene", Qt::QueuedConnection, Q_ARG(QString, QString(sceneName)));
}
示例10: getParamInfo
void SocketController::getVlanSettings()
{
if (!connectionLost)
{
vlanSubtab->setProperty("init", true);
vlanTabId->setProperty("init", true);
//QString vlanType = "portBased";//"802.1q";//
QString vlanType = getParamInfo("VlanType");
if(vlanType == emptyString)
{
logOutSignal();
return;
}
vlanTypeComboBox->setProperty("currentIndex",
findIndexByValue(vlanTypeList, vlanTypeCount,
vlanType));
if(vlanType != "noVlan")
{
//portCount = 8;
QString portCountStr = getParamInfo("PortCount");
if(portCountStr == emptyString)
{
logOutSignal();
return;
}
portCount = portCountStr.toInt();
QVariant retValue;
QMetaObject::invokeMethod(vlanCurrentModel, "init",
Q_RETURN_ARG(QVariant, retValue),
Q_ARG(QVariant, portCount),
Q_ARG(QVariant, vlanCount));
portRepeater->setProperty("model", portCount);
QMetaObject::invokeMethod(vlanCurrentModel, "deleteAllChecks",
Q_RETURN_ARG(QVariant, retValue));
VlanSettingsParser* parser = new VlanSettingsParser();
QString portVlanData = getParamInfo("VlanSettings");
// QString portVlanData = "1 1\n2 1\n3 1\n1 3\n4 2\n5 2\n6 2\n7 3\n8 3\n";//
if(portVlanData == emptyString)
{
logOutSignal();
return;
}
QList<QPair<int, int>> portVlanDataResult = parser->parsePortVlanData(portVlanData);
for (int i = 0; i < portVlanDataResult.count(); i++)
{
QPair<int, int> portVlanPair = portVlanDataResult.at(i);
QMetaObject::invokeMethod(vlanCurrentModel, "addPortVlanEnabled",
Q_RETURN_ARG(QVariant, retValue),
Q_ARG(QVariant, portVlanPair.first),
Q_ARG(QVariant, portVlanPair.second));
}
//QString portPvidData = "1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n7 7\n8 8\n"; //
QString portPvidData = getParamInfo("PortsPvid");
if(portPvidData == emptyString)
{
logOutSignal();
return;
}
QMap<int, int> portPvidDataResult = parser->parsePortPvidData(portPvidData);
for(int port = 1; port <= portCount; port++)
{
QMetaObject::invokeMethod(vlanCurrentModel, "setPortPvid",
Q_RETURN_ARG(QVariant, retValue),
Q_ARG(QVariant, port),
Q_ARG(QVariant, portPvidDataResult[port]));
}
if (vlanType == "802.1q")
{
//QString portTaggingData = "1 On\n2 Off\n3 On\n4 On\n5 On\n6 On\n7 On\n8 On\n";//
QString portTaggingData = getParamInfo("PortsTaggingStatus");
if(portTaggingData == emptyString)
{
logOutSignal();
return;
}
QMap<int, QString> portTaggingDataResult = parser->parsePortTaggingData(portTaggingData);
for(int port = 1; port <= portCount; port++)
//.........这里部分代码省略.........
示例11: qfLogFuncFrame
bool EventPlugin::createEvent(const QString &event_name, const QVariantMap &event_params)
{
qfLogFuncFrame();
closeEvent();
qff::MainWindow *fwk = qff::MainWindow::frameWork();
EventPlugin::ConnectionType connection_type = connectionType();
QStringList existing_event_ids;
if(connection_type == ConnectionType::SingleFile)
existing_event_ids = existingFileEventNames();
else
existing_event_ids = existingSqlEventNames();
QString event_id = event_name;
QVariantMap new_params = event_params;
do {
qfd::Dialog dlg(fwk);
dlg.setButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
EventDialogWidget *event_w = new EventDialogWidget();
event_w->setEventId(event_id);
event_w->loadParams(new_params);
dlg.setCentralWidget(event_w);
if(!dlg.exec())
return false;
event_id = event_w->eventId();
new_params = event_w->saveParams();
if(event_id.isEmpty()) {
qf::qmlwidgets::dialogs::MessageBox::showError(fwk, tr("Event ID cannot be empty."));
continue;
}
if(existing_event_ids.contains(event_id)) {
qf::qmlwidgets::dialogs::MessageBox::showError(fwk, tr("Event ID %1 exists already.").arg(event_id));
continue;
}
break;
} while(true);
bool ok = false;
Event::EventConfig event_config;
//ConnectionSettings connection_settings;
event_config.setValue("event", new_params);
int stage_count = event_params.value("stageCount").toInt();
if(stage_count == 0)
stage_count = event_config.stageCount();
qfInfo() << "createEvent, stage_count:" << stage_count;
QF_ASSERT(stage_count > 0, "Stage count have to be greater than 0", return false);
qfInfo() << "will create:" << event_id;
qfs::Connection conn = qfs::Connection::forName();
//QF_ASSERT(conn.isOpen(), "Connection is not open", return false);
if(connection_type == ConnectionType::SingleFile) {
QString event_fn = eventNameToFileName(event_id);
conn.close();
conn.setDatabaseName(event_fn);
conn.open();
}
if(conn.isOpen()) {
QVariantMap create_options;
create_options["schemaName"] = event_id;
create_options["driverName"] = conn.driverName();
QVariant ret_val;
QMetaObject::invokeMethod(this, "createDbSqlScript", Qt::DirectConnection,
Q_RETURN_ARG(QVariant, ret_val),
Q_ARG(QVariant, create_options));
QStringList create_script = ret_val.toStringList();
qfInfo().nospace() << create_script.join(";\n") << ';';
qfs::Query q(conn);
do {
qfs::Transaction transaction(conn);
ok = run_sql_script(q, create_script);
if(!ok)
break;
qfDebug() << "creating stages:" << stage_count;
QString stage_table_name = "stages";
if(connection_type == ConnectionType::SqlServer)
stage_table_name = event_id + '.' + stage_table_name;
q.prepare("INSERT INTO " + stage_table_name + " (id) VALUES (:id)");
for(int i=0; i<stage_count; i++) {
q.bindValue(":id", i+1);
ok = q.exec();
if(!ok) {
break;
}
}
if(!ok)
break;
conn.setCurrentSchema(event_id);
event_config.save();
transaction.commit();
} while(false);
if(!ok) {
qfd::MessageBox::showError(fwk, tr("Create Database Error: %1").arg(q.lastError().text()));
}
}
else {
qfd::MessageBox::showError(fwk, tr("Cannot create event, database is not open: %1").arg(conn.lastError().text()));
}
if(ok) {
//.........这里部分代码省略.........
示例12: Q_ARG
void LogicManager::restartWithNewProfile(QString uid)
{
QMetaObject::invokeMethod(this, "onRestartWithNewProfile",
Qt::QueuedConnection,
Q_ARG(QString, uid));
}
示例13: switch
bool
SourceDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index )
{
QMouseEvent* mEvent = 0;
switch ( event->type() )
{
// case QEvent::MouseTrackingChange:
case QEvent::MouseButtonDblClick:
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease:
case QEvent::MouseMove:
mEvent = static_cast< QMouseEvent* >( event );
default:
break;
}
bool hoveringTrack = false;
if ( m_trackRects.contains( index ) && mEvent )
{
const QRect trackRect = m_trackRects[ index ];
hoveringTrack = trackRect.contains( mEvent->pos() );
if ( hoveringTrack )
{
if ( m_trackHovered != index )
{
m_trackHovered = index;
QMetaObject::invokeMethod( m_parent, "update", Qt::QueuedConnection, Q_ARG( QModelIndex, index ) );
}
}
}
if ( !hoveringTrack )
{
if ( m_trackHovered.isValid() )
QMetaObject::invokeMethod( m_parent, "update", Qt::QueuedConnection, Q_ARG( QModelIndex, m_trackHovered ) );
m_trackHovered = QPersistentModelIndex();
}
bool lockRectContainsClick = false, headphonesRectContainsClick = false;
if ( m_headphoneRects.contains( index ) && mEvent )
{
const QRect headphoneRect = m_headphoneRects[ index ];
headphonesRectContainsClick = headphoneRect.contains( mEvent->pos() );
}
if ( m_lockRects.contains( index ) && mEvent )
{
const QRect lockRect = m_lockRects[ index ];
lockRectContainsClick = lockRect.contains( mEvent->pos() );
}
if ( event->type() == QEvent::MouseMove )
{
if ( hoveringTrack || lockRectContainsClick || headphonesRectContainsClick )
m_parent->setCursor( Qt::PointingHandCursor );
else
m_parent->setCursor( Qt::ArrowCursor );
}
if ( event->type() == QEvent::MouseButtonRelease || event->type() == QEvent::MouseButtonPress )
{
SourcesModel::RowType type = static_cast< SourcesModel::RowType >( index.data( SourcesModel::SourceTreeItemTypeRole ).toInt() );
if ( type == SourcesModel::TemporaryPage || type == SourcesModel::DeletablePage || type == SourcesModel::RemovablePage )
{
SourceTreeItem* gpi = index.data( SourcesModel::SourceTreeItemRole ).value< SourceTreeItem* >();
Q_ASSERT( gpi );
QStyleOptionViewItemV4 o = option;
initStyleOption( &o, index );
const int padding = m_margin / 8;
const QRect r( o.rect.right() - padding - m_iconHeight, padding + o.rect.y(), m_iconHeight, m_iconHeight );
if ( r.contains( mEvent->pos() ) )
{
if ( event->type() == QEvent::MouseButtonRelease && mEvent->button() == Qt::LeftButton )
{
gpi->removeFromList();
// Send a new mouse event to the view, since if the mouse is now over another item's delete area we want it to show up
QMouseEvent* ev = new QMouseEvent( QEvent::MouseMove, m_parent->viewport()->mapFromGlobal( QCursor::pos() ), Qt::NoButton, Qt::NoButton, Qt::NoModifier );
QApplication::postEvent( m_parent->viewport(), ev );
}
return true;
}
}
else if ( type == SourcesModel::Source )
{
SourceItem* colItem = qobject_cast< SourceItem* >( index.data( SourcesModel::SourceTreeItemRole ).value< SourceTreeItem* >() );
Q_ASSERT( colItem );
if ( hoveringTrack && colItem->source() && colItem->source()->currentTrack() )
{
if ( event->type() == QEvent::MouseButtonRelease && mEvent->button() == Qt::LeftButton )
{
ViewManager::instance()->show( colItem->source()->currentTrack() );
return true;
}
else if ( event->type() == QEvent::MouseButtonPress && mEvent->button() == Qt::RightButton )
{
//.........这里部分代码省略.........
示例14: Q_UNUSED
void QxtMDNSPrivate::avahiRecordBrowserCallback(AvahiRecordBrowser *b, AvahiIfIndex interface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *name, uint16_t clazz, uint16_t type, const void *rdata, size_t size, AvahiLookupResultFlags flags, void *userdata)
{
///@TODO Support IPv6
Q_UNUSED(interface);
Q_UNUSED(protocol);
Q_UNUSED(name);
Q_UNUSED(clazz);
Q_UNUSED(type);
Q_UNUSED(size);
Q_UNUSED(flags);
QxtMDNSPrivate* self = static_cast<QxtMDNSPrivate*>(userdata);
self->recordbrowser = b;
// qDebug() << "Return thing" << md->name << name << size;
switch (event)
{
case AVAHI_BROWSER_NEW:
{
//Found an entry!
uint32_t ip = qFromBigEndian(*static_cast<const uint32_t*>(rdata));
if (self->sent)
{
QHostInfo info(self->info.lookupId());
info.setAddresses(QList<QHostAddress>() << QHostAddress(ip));
QMetaObject::invokeMethod(self->receiver, self->member, Q_ARG(QHostInfo, info));
}
else
{
self->addresses << QHostAddress(ip);
}
break;
}
case AVAHI_BROWSER_REMOVE:
{
uint32_t ip = qFromBigEndian(*static_cast<const uint32_t*>(rdata));
self->addresses.removeAll(QHostAddress(ip));
break;
}
case AVAHI_BROWSER_CACHE_EXHAUSTED:
break;
case AVAHI_BROWSER_ALL_FOR_NOW:
if (self->addresses.count() == 0)
{
self->info.setError(QHostInfo::HostNotFound);
self->info.setErrorString("The host was not found.");
}
else
{
self->info.setAddresses(self->addresses);
self->addresses.clear();
}
QMetaObject::invokeMethod(self->receiver, self->member, Q_ARG(QHostInfo, self->info));
self->sent = true;
break;
case AVAHI_BROWSER_FAILURE:
if (self->sent)
{
QHostInfo info(self->info.lookupId());
info.setError(QHostInfo::UnknownError);
info.setErrorString(avahi_strerror(avahi_client_errno(self->client)));
info.setAddresses(self->addresses);
QMetaObject::invokeMethod(self->receiver, self->member, Q_ARG(QHostInfo, info));
}
else
{
self->info.setError(QHostInfo::UnknownError);
self->info.setErrorString(avahi_strerror(avahi_client_errno(self->client)));
self->info.setAddresses(self->addresses);
self->addresses.clear();
QMetaObject::invokeMethod(self->receiver, self->member, Q_ARG(QHostInfo, self->info));
self->sent = true;
}
break;
}
}
示例15: Q_ARG
void PresentationDisplayTask::showHidePanel(bool show)
{
QVariant showHide = QVariant::fromValue(show);
QMetaObject::invokeMethod(m_panel, "showHidePresentation", Q_ARG(QVariant, showHide));
}