当前位置: 首页>>代码示例>>C++>>正文


C++ QLatin1Literal函数代码示例

本文整理汇总了C++中QLatin1Literal函数的典型用法代码示例。如果您正苦于以下问题:C++ QLatin1Literal函数的具体用法?C++ QLatin1Literal怎么用?C++ QLatin1Literal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了QLatin1Literal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: resolveFileName

QT_BEGIN_NAMESPACE

static QString resolveFileName(QString fileName, QUrl *url, qreal targetDevicePixelRatio)
{
    // We might use the fileName for loading if url loading fails
    // try to make sure it is a valid file path.
    // Also, QFile{Info}::exists works only on filepaths (not urls)

    if (url->isValid()) {
      if (url->scheme() == QLatin1Literal("qrc")) {
        fileName = fileName.right(fileName.length() - 3);
      }
      else if (url->scheme() == QLatin1Literal("file")) {
        fileName = url->toLocalFile();
      }
    }

    if (targetDevicePixelRatio <= 1.0)
        return fileName;

    // try to find a 2x version

    const int dotIndex = fileName.lastIndexOf(QLatin1Char('.'));
    if (dotIndex != -1) {
        QString at2xfileName = fileName;
        at2xfileName.insert(dotIndex, QStringLiteral("@2x"));
        if (QFile::exists(at2xfileName))  {
            fileName = at2xfileName;
            *url = QUrl(fileName);
        }
    }

    return fileName;
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:34,代码来源:qtextimagehandler.cpp

示例2: message_handler

void
message_handler(QtMsgType type, const QMessageLogContext & context, const QString & message)
{
  QString formated_message;
  QString (*formater)(const QString & message_type, const QMessageLogContext & context, const QString & message);
  // formater = format_log;
#ifdef ANDROID
  formater = format_log;
#else
  formater = format_log_with_ansi;
#endif

  switch (type) {
  case QtDebugMsg:
    formated_message = formater(QLatin1Literal("Debug"), context, message);
    break;
  case QtInfoMsg:
    formated_message = formater(QLatin1Literal("Info"), context, message);
    break;
  case QtWarningMsg:
    formated_message = formater(QLatin1Literal("Warning"), context, message);
    break;
  case QtCriticalMsg:
    formated_message = formater(QLatin1Literal("Critical"), context, message);
    break;
  case QtFatalMsg:
    formated_message = formater(QLatin1Literal("Fatal"), context, message);
  }

  // stderr
  fprintf(stdout, formated_message.toStdString().c_str()); //  # QByteArray local_message = message.toLocal8Bit();

  if (type == QtFatalMsg)
    abort();
}
开发者ID:FabriceSalvaire,项目名称:qtcarto,代码行数:35,代码来源:logger.cpp

示例3: updateSvgIds

void GameScene::updateSvgIds()
{
    //Needed so new boundingRects() are read for all SVG elements after a theme change
    // Sanity check, see if game elements already exist
    if (!m_kapmanItem) {
        return;
    }

    // Set the element Id to the right value
    m_mazeItem->setElementId(QLatin1Literal("maze"));

    // Create the KapmanItem
    m_kapmanItem->setElementId(QLatin1Literal("kapman_0"));
    // Corrects the position of the KapmanItem
    m_kapmanItem->update(m_game->getKapman()->getX(), m_game->getKapman()->getY());

    for (int i = 0; i < m_ghostItems.size(); ++i) {
        GhostItem *ghost = m_ghostItems[i];
        ghost->setElementId(m_game->getGhosts()[i]->getImageId());
        ghost->update(m_game->getGhosts()[i]->getX(), m_game->getGhosts()[i]->getY());
    }
    for (int i = 0; i < m_game->getMaze()->getNbRows(); ++i) {
        for (int j = 0; j < m_game->getMaze()->getNbColumns(); ++j) {
            if (m_elementItems[i][j] != NULL) {
                ElementItem *element = m_elementItems[i][j];
                element->setElementId(m_game->getMaze()->getCell(i, j).getElement()->getImageId());
                element->update(m_game->getMaze()->getCell(i, j).getElement()->getX(), m_game->getMaze()->getCell(i, j).getElement()->getY());
            }
        }
    }
}
开发者ID:KDE,项目名称:kapman,代码行数:31,代码来源:gamescene.cpp

示例4: res

QVariantMap PersonInfoData::data() const
{
	QResource res(QLatin1Literal(":/devels/") % ocsUsername % QLatin1Literal(".json"));
	if (!res.isValid())
		res.setFileName(QLatin1Literal(":/contributers/") % ocsUsername % QLatin1Literal(".json"));
	return qutim_resource_open(res);
}
开发者ID:CyberSys,项目名称:qutim,代码行数:7,代码来源:personinfo.cpp

示例5: QLatin1Literal

void KSecretServiceTest::testItems()
{
    auto NEW_ITEM_NAME = QLatin1Literal("Test Item1");
    auto NEW_ITEM_VALUE = QLatin1Literal("highly secret value");
    QDateTime testTime = QDateTime::currentDateTime();

    KSecrets::Secret secret;
    secret.setValue(NEW_ITEM_VALUE);
    auto createRes = collection->createItem(NEW_ITEM_NAME, secret).result();
    QVERIFY(createRes);

    auto foundItems = collection->searchItems(NEW_ITEM_NAME).result();
    QVERIFY(foundItems.length() == 1);

    auto theItem = foundItems.first();
    QCOMPARE(theItem->label().result(), NEW_ITEM_NAME);
    QVERIFY(theItem->createdTime().result() > testTime);
    QVERIFY(theItem->modifiedTime().result() > testTime);

    QDateTime oldModifiedTime = theItem->modifiedTime().result();
    QVERIFY(theItem->setLabel(NEW_ITEM_NAME).result());
    QVERIFY(theItem->modifiedTime().result()
        == oldModifiedTime); // name was the same so item should have stayed
                             // the same

    auto NEW_ITEM_SECOND_NAME = QLatin1Literal("Test Item2");
    QVERIFY(theItem->setLabel(NEW_ITEM_SECOND_NAME).result());
    QCOMPARE(theItem->label().result(), NEW_ITEM_SECOND_NAME);
    QVERIFY(theItem->modifiedTime().result() > oldModifiedTime);

    auto theSecret = theItem->getSecret().result();
    QCOMPARE(theSecret->value().toString(), NEW_ITEM_VALUE);
}
开发者ID:KDE,项目名称:ksecrets,代码行数:33,代码来源:ksecretsservice-test.cpp

示例6: switch

void GhostItem::updateState()
{
    // Stop timers
    if (m_startBlinkingTimer->isActive()) {
        m_startBlinkingTimer->stop();
    }
    if (m_blinkTimer->isActive()) {
        m_blinkTimer->stop();
    }
    switch (((Ghost *)getModel())->getState()) {
    case Ghost::PREY:
        updateBlinkTimersDuration();
        setElementId(QLatin1Literal("scaredghost"));
        m_startBlinkingTimer->start();
        // The ghosts are now weaker than the kapman, so they are under him
        setZValue(1);
        break;
    case Ghost::HUNTER:
        setElementId(((Ghost *)getModel())->getImageId());
        // The ghosts are stronger than the kapman, they are above him
        setZValue(3);
        break;
    case Ghost::EATEN:
        setElementId(QLatin1Literal("ghosteye"));
        // The ghosts are now weaker than the kapman, so they are under him
        setZValue(1);
        break;
    }
}
开发者ID:KDE,项目名称:kapman,代码行数:29,代码来源:ghostitem.cpp

示例7: test_byteArray_equals_latin1Literal

	void test_byteArray_equals_latin1Literal()
	{
		Pillow::ByteArray ba; ba = QByteArray("Some-string");
		QVERIFY(ba == QLatin1Literal("Some-string"));
		QVERIFY(!(ba == QLatin1Literal("Some-other-string")));
		QVERIFY(ba != QLatin1Literal("Some-other-string"));
		QVERIFY(!(ba != QLatin1Literal("Some-string")));
	}
开发者ID:xiaowentao99,项目名称:pillow,代码行数:8,代码来源:ByteArrayHelpersTest.cpp

示例8: QNetworkAccessManager

void RssFeedNode::render(Grantlee::OutputStream* stream, Grantlee::Context* c)
{
  QNetworkAccessManager *mgr = new QNetworkAccessManager(this);
  QUrl url(Grantlee::getSafeString(m_url.resolve(c)));
  QNetworkReply *reply = mgr->get(QNetworkRequest(url));
  QEventLoop eLoop;
  connect( mgr, SIGNAL( finished( QNetworkReply * ) ), &eLoop, SLOT( quit() ) );
  eLoop.exec( QEventLoop::ExcludeUserInputEvents );

  c->push();
  foreach(Grantlee::Node *n, m_childNodes) {
    if (!n->inherits(XmlNamespaceNode::staticMetaObject.className()))
      continue;
    Grantlee::OutputStream _dummy;
    n->render(&_dummy, c);
  }

  QXmlQuery query;
  QByteArray ba = reply->readAll();

  QBuffer buffer;
  buffer.setData(ba);
  buffer.open(QIODevice::ReadOnly);
  query.bindVariable("inputDocument", &buffer);
  QString ns;
  QHash<QString, QVariant> h = c->lookup("_ns").toHash();
  QHash<QString, QVariant>::const_iterator it = h.constBegin();
  const QHash<QString, QVariant>::const_iterator end = h.constEnd();
  for ( ; it != end; ++it ) {
    if (it.key().isEmpty()) {
      ns += QLatin1Literal( "declare default element namespace " ) + QLatin1Literal( " \"" ) + it.value().toString() + QLatin1Literal( "\";\n" );
    } else {
      ns += QLatin1Literal( "declare namespace " ) + it.key() + QLatin1Literal( " = \"" ) + it.value().toString() + QLatin1Literal( "\";\n" );
    }
  }
  query.setQuery(ns + "doc($inputDocument)" + Grantlee::getSafeString(m_query.resolve(c)).get());

  QXmlResultItems result;
  query.evaluateTo(&result);

  QXmlItem item(result.next());
  int count = 0;
  while (!item.isNull()) {
      if (count++ > 20)
        break;
      query.setFocus(item);
      c->push();
      foreach(Grantlee::Node *n, m_childNodes) {
        if (n->inherits(XmlNamespaceNode::staticMetaObject.className()))
          continue;
        c->insert("_q", QVariant::fromValue(query));
        n->render(stream, c);
      }
      c->pop();
      item = result.next();
  }
  c->pop();
}
开发者ID:hicknhack-software,项目名称:Qt-Grantlee,代码行数:58,代码来源:rssfeed.cpp

示例9: QLatin1Literal

void SqlBulkInsert::flush()
{
  if (_pending.size() > 0)
  {
    double start = Tgs::Time::getTime();
    QString sql;
    // the value 22 was found experimentally
    sql.reserve(_pending.size() * _columns.size() * 22);
    sql.append(QLatin1Literal("INSERT INTO ") %
        _tableName %
        QLatin1Literal(" (") %
        _columns.join(",") %
        QLatin1Literal(") VALUES "));

    QLatin1String firstOpenParen("("), openParen(",("), closeParen(")"), comma(",");

    for (int i = 0; i < _pending.size(); i++)
    {
      if (i == 0)
      {
        sql.append(firstOpenParen);
      }
      else
      {
        sql.append(openParen);
      }

      for (int j = 0; j < _columns.size(); j++)
      {
        if (j == 0)
        {
          sql.append(_escape(_pending[i][j]));
        }
        else
        {
          sql.append(comma % _escape(_pending[i][j]));
        }
      }

      sql.append(closeParen);
    }

    //LOG_VAR(sql.size());
    QSqlQuery q(_db);
    if (q.exec(sql) == false)
    {
      throw HootException(QString("Error executing bulk insert: %1 (%2)").arg(q.lastError().text()).
                          arg(sql));
    }

    q.finish();

    _pending.clear();
    double elapsed = Tgs::Time::getTime() - start;
    _time += elapsed;
  }
}
开发者ID:BSteine,项目名称:hootenanny,代码行数:57,代码来源:SqlBulkInsert.cpp

示例10: setElementId

void GhostItem::blink()
{
    CharacterItem::blink();
    if (m_nbBlinks % 2 == 0) {
        setElementId(QLatin1Literal("scaredghost"));
    } else {
        setElementId(QLatin1Literal("whitescaredghost"));
    }
}
开发者ID:KDE,项目名称:kapman,代码行数:9,代码来源:ghostitem.cpp

示例11: init_qt_late

void init_qt_late()
{
	QApplication *application = qApp;
	// tell Qt to use system proxies
	// note: on Linux, "system" == "environment variables"
	QNetworkProxyFactory::setUseSystemConfiguration(true);

	// for Win32 and Qt5 we try to set the locale codec to UTF-8.
	// this makes QFile::encodeName() work.
#ifdef Q_OS_WIN
	QTextCodec::setCodecForLocale(QTextCodec::codecForMib(106));
#endif

	QCoreApplication::setOrganizationName("Subsurface");
	QCoreApplication::setOrganizationDomain("subsurface.hohndel.org");
	// enable user specific settings (based on command line argument)
	if (settings_suffix) {
		if (verbose)
			qDebug() << "using custom config for" << QString("Subsurface-%1").arg(settings_suffix);
		QCoreApplication::setApplicationName(QString("Subsurface-%1").arg(settings_suffix));
	} else {
		QCoreApplication::setApplicationName("Subsurface");
	}
	// find plugins installed in the application directory (without this SVGs don't work on Windows)
	SettingsObjectWrapper::instance()->load();

	QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath());
	QLocale loc;
	QString uiLang = uiLanguage(&loc);
	QLocale::setDefault(loc);

	qtTranslator = new QTranslator;
	QString translationLocation;
#if defined(Q_OS_ANDROID)
	translationLocation = QLatin1Literal("assets:/translations");
#elif defined(Q_OS_IOS)
	translationLocation = QLatin1Literal(":/translations/");
#else
	translationLocation = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
#endif
	if (qtTranslator->load(loc, "qt", "_", translationLocation)) {
		application->installTranslator(qtTranslator);
	} else {
		if (uiLang != "en_US" && uiLang != "en-US")
			qDebug() << "can't find Qt localization for locale" << uiLang << "searching in" << translationLocation;
	}
	ssrfTranslator = new QTranslator;
	if (ssrfTranslator->load(loc, "subsurface", "_") ||
	    ssrfTranslator->load(loc, "subsurface", "_", translationLocation) ||
	    ssrfTranslator->load(loc, "subsurface", "_", getSubsurfaceDataPath("translations")) ||
	    ssrfTranslator->load(loc, "subsurface", "_", getSubsurfaceDataPath("../translations"))) {
		application->installTranslator(ssrfTranslator);
	} else {
		qDebug() << "can't find Subsurface localization for locale" << uiLang;
	}
}
开发者ID:neolit123,项目名称:subsurface,代码行数:56,代码来源:qt-init.cpp

示例12: main

int main(int argc, char ** argv) {
    QCoreApplication app(argc, argv);
#if defined(Q_OS_UNIX)
    catchUnixSignals({SIGQUIT, SIGINT, SIGTERM, SIGHUP});
#endif

    app.setApplicationName("helloworld");
    app.setApplicationVersion("1.0.0");

    QCommandLineParser parser;
    parser.setApplicationDescription("a HelloWorld example for http client and server.");
    parser.addHelpOption();
    parser.addVersionOption();
    parser.addPositionalArgument("mode",
            "working mode: server, client or weather. default: server");

//    parser.addOption({
//            {"l", "listen"},
//            "listening tcp port number in server mode (default 8080)",
//            "portNo", "8080"});
//    parser.addOption({
//            {"u", "url"},
//            "fetch url data in client mode",
//            "address", "http://www.google.com"});
//    parser.addOption({
//            {"g", "geolocation"},
//            "a city name [,country name] in weather mode, default: Tehran",
//            "city", "Tehran"});
    parser.process(app);


    QStringList posArgs = parser.positionalArguments();
    if ( posArgs.size() != 1 ) {
        parser.showHelp(0);

    } else {
        const auto& mode = posArgs.at(0);

        if ( mode == QLatin1Literal("server") )
            runServer(parser.value("listen"));

#if defined(QHTTP_HAS_CLIENT)
        else if ( mode == QLatin1Literal("client") )
            runClient(parser.value("url"));

        else if ( mode == QLatin1Literal("weather") )
            runWeatherClient(parser.value("geolocation"));
#else
        else if ( mode == QLatin1Literal("client")
                || mode == QLatin1Literal("weather") )
            qDebug("qhttp::client has not been enabled at build time");
#endif // QHTTP_HAS_CLIENT
    }

    return 0;
}
开发者ID:oliviermaridat,项目名称:qhttp,代码行数:56,代码来源:main.cpp

示例13: SLOT

void MainWindow::setupActions()
{
    KStandardGameAction::gameNew(m_main, SLOT(newGame()), actionCollection());
    KStandardGameAction::restart(m_main, SLOT(restart()), actionCollection());
    KStandardGameAction::highscores(m_main, SLOT(highscores()), actionCollection());
    
    KStandardGameAction::quit(this, SLOT(close()), actionCollection());
    
    QAction* action;
    action = new QAction(i18n("&Single Player"), this);
    action->setIcon(QIcon::fromTheme( QLatin1String( SimpleMenu::iconLocal)));
    actionCollection()->addAction(QLatin1Literal("game_local"), action);
    connect(action, &QAction::triggered, m_main, &PlayField::localGame);
    action = new QAction(i18n("&Host Game..."), this);
    action->setIcon(QIcon::fromTheme( QLatin1String( SimpleMenu::iconServer)));
    actionCollection()->addAction(QLatin1Literal("game_create_server"), action);
    connect(action, &QAction::triggered, m_main, &PlayField::createServer);
    action = new QAction(i18n("&Connect to Game..."), this);
    action->setIcon(QIcon::fromTheme( QLatin1String( SimpleMenu::iconClient))),
    actionCollection()->addAction(QLatin1Literal("game_create_client"), action);
    connect(action, &QAction::triggered, m_main, &PlayField::createClient);
    // settings
    action = new QAction(i18n("Change &Nickname..."), this);
    actionCollection()->addAction(QLatin1Literal("options_nickname"), action);
    connect(action, &QAction::triggered, m_main, &PlayField::changeNick);
    action = new KToggleAction(i18n("&Play Sounds"), this);
    action->setChecked(Settings::enableSounds());
    actionCollection()->addAction(QLatin1Literal("options_sounds"), action);
    connect(action, &QAction::triggered, m_main, &PlayField::toggleSounds);
    // This action will be disabled when a game is being run
    action = new KToggleAction(i18n("&Adjacent Ships"), this);
    action->setChecked(Settings::adjacentShips());
    actionCollection()->addAction(QLatin1Literal("options_adjacent"), action);
    connect(action, &QAction::triggered, m_main, &PlayField::toggleAdjacent);
    // This action will be disabled when a game is being run
    action = new KToggleAction(i18n("&Multiple Ships"), this);
    action->setChecked(Settings::severalShips());
    actionCollection()->addAction(QLatin1Literal("options_multiple_ships"), action);
    connect(action, &QAction::triggered, m_main, &PlayField::toggleMultiple);
    // config end of game message
    action = new KToggleAction(i18n("Show End-of-Game Message"), this);
    action->setChecked(true);
    actionCollection()->addAction(QLatin1Literal("options_show_endgame_message"), action);
    connect(action, &QAction::triggered, m_main, &PlayField::toggleEndOfGameMessage);
    // actions for grid
    action = new KToggleAction(i18n("Show &Left Grid"), this);
    action->setChecked(true);
    actionCollection()->addAction(QLatin1Literal("options_showleftgrid"), action);
    connect(action, &QAction::triggered, m_main, &PlayField::toggleLeftGrid);
    action = new KToggleAction(i18n("Show &Right Grid"), this);
    action->setChecked(true);
    actionCollection()->addAction(QLatin1Literal("options_showrightgrid"), action);
    connect(action, &QAction::triggered, m_main, &PlayField::toggleRightGrid);
    
    setupGUI();
}
开发者ID:KDE,项目名称:knavalbattle,代码行数:56,代码来源:mainwindow.cpp

示例14: QMainWindow

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow())
{
    ui->setupUi(this);

    PositioningMenuBar *menuBar = new PositioningMenuBar(ui->menuBar);

    QMenu *menuOptions = menuBar->addMenu(QLatin1Literal("&Options"));
    menuOptions->addAction(QLatin1Literal("About Qt"));
}
开发者ID:Iownnoname,项目名称:qt,代码行数:11,代码来源:mainwindow.cpp

示例15: config_get_ptr

void ShaderParamsDialog::onShaderLoadPresetClicked()
{
   QString path;
   QString filter;
   QByteArray pathArray;
   struct video_shader *menu_shader = NULL;
   struct video_shader *video_shader = NULL;
   const char *pathData = NULL;
   settings_t *settings = config_get_ptr();
   enum rarch_shader_type type = RARCH_SHADER_NONE;
   bool is_preset = false;

   if (!settings)
      return;

   getShaders(&menu_shader, &video_shader);

   if (!menu_shader)
      return;

   filter = "Shader Preset (";

   /* NOTE: Maybe we should have a way to get a list of all shader types instead of hard-coding this? */
   if (video_shader_is_supported(RARCH_SHADER_CG) &&
         video_shader_get_type_from_ext(file_path_str(FILE_PATH_CGP_EXTENSION), &is_preset)
         != RARCH_SHADER_NONE)
      filter += QLatin1Literal("*") + file_path_str(FILE_PATH_CGP_EXTENSION);

   if (video_shader_is_supported(RARCH_SHADER_GLSL) &&
         video_shader_get_type_from_ext(file_path_str(FILE_PATH_GLSLP_EXTENSION), &is_preset)
         != RARCH_SHADER_NONE)
      filter += QLatin1Literal(" *") + file_path_str(FILE_PATH_GLSLP_EXTENSION);

   if (video_shader_is_supported(RARCH_SHADER_SLANG) &&
         video_shader_get_type_from_ext(file_path_str(FILE_PATH_SLANGP_EXTENSION), &is_preset)
         != RARCH_SHADER_NONE)
      filter += QLatin1Literal(" *") + file_path_str(FILE_PATH_SLANGP_EXTENSION);

   filter += ")";

   path = QFileDialog::getOpenFileName(this, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_VIDEO_SHADER_PRESET), settings->paths.directory_video_shader, filter);

   if (path.isEmpty())
      return;

   pathArray = path.toUtf8();
   pathData = pathArray.constData();

   type = video_shader_parse_type(pathData, RARCH_SHADER_NONE);

   menu_shader_manager_set_preset(menu_shader, type, pathData);
}
开发者ID:DSkywalk,项目名称:RetroArch,代码行数:52,代码来源:shaderparamsdialog.cpp


注:本文中的QLatin1Literal函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。