本文整理汇总了C++中qstringlist::iterator::toUtf8方法的典型用法代码示例。如果您正苦于以下问题:C++ iterator::toUtf8方法的具体用法?C++ iterator::toUtf8怎么用?C++ iterator::toUtf8使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qstringlist::iterator
的用法示例。
在下文中一共展示了iterator::toUtf8方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main( int argc, char ** argv )
{
#if defined (FC_OS_LINUX) || defined(FC_OS_BSD)
// Make sure to setup the Qt locale system before setting LANG and LC_ALL to C.
// which is needed to use the system locale settings.
(void)QLocale::system();
#if QT_VERSION < 0x050000
// http://www.freecadweb.org/tracker/view.php?id=399
// Because of setting LANG=C the Qt automagic to use the correct encoding
// for file names is broken. This is a workaround to force the use of UTF-8 encoding
QFile::setEncodingFunction(myEncoderFunc);
QFile::setDecodingFunction(myDecoderFunc);
#endif
// See https://forum.freecadweb.org/viewtopic.php?f=18&t=20600
// See Gui::Application::runApplication()
putenv("LC_NUMERIC=C");
putenv("PYTHONPATH=");
#elif defined(FC_OS_MACOSX)
(void)QLocale::system();
putenv("PYTHONPATH=");
#else
_putenv("PYTHONPATH=");
// https://forum.freecadweb.org/viewtopic.php?f=4&t=18288
// https://forum.freecadweb.org/viewtopic.php?f=3&t=20515
const char* fc_py_home = getenv("FC_PYTHONHOME");
if (fc_py_home)
_putenv_s("PYTHONHOME", fc_py_home);
else
_putenv("PYTHONHOME=");
#endif
#if defined (FC_OS_WIN32)
int argc_ = argc;
QVector<QByteArray> data;
QVector<char *> argv_;
// get the command line arguments as unicode string
{
QCoreApplication app(argc, argv);
QStringList args = app.arguments();
for (QStringList::iterator it = args.begin(); it != args.end(); ++it) {
data.push_back(it->toUtf8());
argv_.push_back(data.back().data());
}
argv_.push_back(0); // 0-terminated string
}
#endif
#if PY_MAJOR_VERSION >= 3
#if defined(_MSC_VER) && _MSC_VER <= 1800
// See InterpreterSingleton::init
Redirection out(stdout), err(stderr), inp(stdin);
#endif
#endif // PY_MAJOR_VERSION
// Name and Version of the Application
App::Application::Config()["ExeName"] = "FreeCAD";
App::Application::Config()["ExeVendor"] = "FreeCAD";
App::Application::Config()["AppDataSkipVendor"] = "true";
App::Application::Config()["MaintainerUrl"] = "http://www.freecadweb.org/wiki/Main_Page";
// set the banner (for logging and console)
App::Application::Config()["CopyrightInfo"] = sBanner;
App::Application::Config()["AppIcon"] = "freecad";
App::Application::Config()["SplashScreen"] = "freecadsplash";
App::Application::Config()["StartWorkbench"] = "StartWorkbench";
//App::Application::Config()["HiddenDockWindow"] = "Property editor";
App::Application::Config()["SplashAlignment" ] = "Bottom|Left";
App::Application::Config()["SplashTextColor" ] = "#ffffff"; // white
App::Application::Config()["SplashInfoColor" ] = "#c8c8c8"; // light grey
try {
// Init phase ===========================================================
// sets the default run mode for FC, starts with gui if not overridden in InitConfig...
App::Application::Config()["RunMode"] = "Gui";
App::Application::Config()["Console"] = "0";
// Inits the Application
#if defined (FC_OS_WIN32)
App::Application::init(argc_, argv_.data());
#else
App::Application::init(argc, argv);
#endif
#if defined(_MSC_VER)
// create a dump file when the application crashes
std::string dmpfile = App::Application::getUserAppDataDir();
dmpfile += "crash.dmp";
InitMiniDumpWriter(dmpfile);
#endif
std::map<std::string, std::string>::iterator it = App::Application::Config().find("NavigationStyle");
if (it != App::Application::Config().end()) {
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View");
// if not already defined do it now (for the very first start)
std::string style = hGrp->GetASCII("NavigationStyle", it->second.c_str());
hGrp->SetASCII("NavigationStyle", style.c_str());
}
Gui::Application::initApplication();
// Only if 'RunMode' is set to 'Gui' do the replacement
//.........这里部分代码省略.........
示例2: main
int main( int argc, char ** argv )
{
#if defined (FC_OS_LINUX) || defined(FC_OS_BSD)
// Make sure to setup the Qt locale system before setting LANG and LC_ALL to C.
// which is needed to use the system locale settings.
(void)QLocale::system();
// http://www.freecadweb.org/tracker/view.php?id=399
// Because of setting LANG=C the Qt automagic to use the correct encoding
// for file names is broken. This is a workaround to force the use of UTF-8 encoding
QFile::setEncodingFunction(myEncoderFunc);
QFile::setDecodingFunction(myDecoderFunc);
// Make sure that we use '.' as decimal point. See also
// http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=559846
putenv("LC_NUMERIC=C");
putenv("PYTHONPATH=");
#elif defined(FC_OS_MACOSX)
(void)QLocale::system();
putenv("LC_NUMERIC=C");
putenv("PYTHONPATH=");
#else
setlocale(LC_NUMERIC, "C");
_putenv("PYTHONPATH=");
#endif
#if defined (FC_OS_WIN32)
int argc_ = argc;
QVector<QByteArray> data;
QVector<char *> argv_;
// get the command line arguments as unicode string
{
QCoreApplication app(argc, argv);
QStringList args = app.arguments();
for (QStringList::iterator it = args.begin(); it != args.end(); ++it) {
data.push_back(it->toUtf8());
argv_.push_back(data.back().data());
}
argv_.push_back(0); // 0-terminated string
}
#endif
// Name and Version of the Application
App::Application::Config()["ExeName"] = "FreeCAD";
App::Application::Config()["ExeVendor"] = "FreeCAD";
App::Application::Config()["AppDataSkipVendor"] = "true";
App::Application::Config()["MaintainerUrl"] = "http://www.freecadweb.org/wiki/index.php?title=Main_Page";
// set the banner (for logging and console)
App::Application::Config()["CopyrightInfo"] = sBanner;
App::Application::Config()["AppIcon"] = "freecad";
App::Application::Config()["SplashScreen"] = "freecadsplash";
App::Application::Config()["StartWorkbench"] = "StartWorkbench";
//App::Application::Config()["HiddenDockWindow"] = "Property editor";
App::Application::Config()["SplashAlignment" ] = "Bottom|Left";
App::Application::Config()["SplashTextColor" ] = "#ffffff"; // white
App::Application::Config()["SplashInfoColor" ] = "#c8c8c8"; // light grey
try {
// Init phase ===========================================================
// sets the default run mode for FC, starts with gui if not overridden in InitConfig...
App::Application::Config()["RunMode"] = "Gui";
// Inits the Application
#if defined (FC_OS_WIN32)
App::Application::init(argc_, argv_.data());
#else
App::Application::init(argc, argv);
#endif
#if defined(_MSC_VER)
// create a dump file when the application crashes
std::string dmpfile = App::Application::getUserAppDataDir();
dmpfile += "crash.dmp";
InitMiniDumpWriter(dmpfile);
#endif
std::map<std::string, std::string>::iterator it = App::Application::Config().find("NavigationStyle");
if (it != App::Application::Config().end()) {
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View");
// if not already defined do it now (for the very first start)
std::string style = hGrp->GetASCII("NavigationStyle", it->second.c_str());
hGrp->SetASCII("NavigationStyle", style.c_str());
}
Gui::Application::initApplication();
// Only if 'RunMode' is set to 'Gui' do the replacement
if (App::Application::Config()["RunMode"] == "Gui")
Base::Interpreter().replaceStdOutput();
}
catch (const Base::UnknownProgramOption& e) {
QApplication app(argc,argv);
QString appName = QString::fromAscii(App::Application::Config()["ExeName"].c_str());
QString msg = QString::fromAscii(e.what());
QString s = QLatin1String("<pre>") + msg + QLatin1String("</pre>");
QMessageBox::critical(0, appName, s);
exit(1);
}
catch (const Base::ProgramInformation& e) {
QApplication app(argc,argv);
QString appName = QString::fromAscii(App::Application::Config()["ExeName"].c_str());
QString msg = QString::fromAscii(e.what());
//.........这里部分代码省略.........
示例3: prepare
int prepare(QFileInfo f, QStringList paths) {
if (paths.isEmpty()) {
cout << "No -path args were passed :(\n";
return -1;
}
int lastVersion = 0;
QString lastVersionStr;
QFileInfo last;
QFileInfoList l = f.absoluteDir().entryInfoList(QDir::Files);
for (QFileInfoList::iterator i = l.begin(), e = l.end(); i != e; ++i) {
QRegularExpressionMatch m = QRegularExpression("/tsetup.((\\d+).(\\d+).(\\d+)).exe$").match(i->absoluteFilePath());
if (!m.hasMatch()) continue;
int version = m.captured(2).toInt() * 1000000 + m.captured(3).toInt() * 1000 + m.captured(4).toInt();
if (version > lastVersion) {
lastVersion = version;
lastVersionStr = m.captured(1);
last = *i;
}
}
if (!lastVersion) {
cout << "No tsetup.X.Y.Z.exe found :(\n";
return -1;
}
cout << "Last version: " << lastVersionStr.toUtf8().constData() << " (" << lastVersion << "), executing packer..\n";
QDir dir("deploy/" + lastVersionStr);
if (dir.exists()) {
cout << "Version " << lastVersionStr.toUtf8().constData() << " already exists in /deploy..\n";
return -1;
}
QString packer = QString("Packer.exe -version %1").arg(lastVersion);
for (QStringList::iterator i = paths.begin(), e = paths.end(); i != e; ++i) {
packer += " -path " + *i;
}
int res = system(packer.toUtf8().constData());
if (res) return res;
dir.mkpath(".");
paths.push_back("Telegram.pdb");
paths.push_back("Updater.pdb");
paths.push_back("tsetup." + lastVersionStr + ".exe");
paths.push_back(QString("tupdate%1").arg(lastVersion));
for (QStringList::iterator i = paths.begin(), e = paths.end(); i != e; ++i) {
if (!QFile::copy(*i, "deploy/" + lastVersionStr + "/" + *i)) {
cout << "Could not copy " << i->toUtf8().constData() << " to deploy/" << lastVersionStr.toUtf8().constData() << "\n";
return -1;
}
cout << "Copied " << i->toUtf8().constData() << "..\n";
}
for (QStringList::iterator i = paths.begin(), e = paths.end(); i != e; ++i) {
QFile::remove(*i);
}
cout << "Update created in deploy/" << lastVersionStr.toUtf8().constData() << "\n";
return 0;
}