本文整理汇总了C++中QTemporaryFile::bytesAvailable方法的典型用法代码示例。如果您正苦于以下问题:C++ QTemporaryFile::bytesAvailable方法的具体用法?C++ QTemporaryFile::bytesAvailable怎么用?C++ QTemporaryFile::bytesAvailable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTemporaryFile
的用法示例。
在下文中一共展示了QTemporaryFile::bytesAvailable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findExternalTTY
bool STTY::findExternalTTY(const QString& termApp)
{
QString appName(termApp.isEmpty() ? QString("xterm") : termApp);
if (QStandardPaths::findExecutable(appName).isEmpty()) {
m_lastError = i18n("%1 is incorrect terminal name", termApp);
return false;
}
QTemporaryFile file;
if (!file.open()) {
m_lastError = i18n("Can't create a temporary file");
return false;
}
m_externalTerminal.reset(new QProcess(this));
if (appName == "konsole") {
m_externalTerminal->start(appName, QStringList() << "-e" << "sh" << "-c" << "tty>" + file.fileName() + ";exec<&-;exec>&-;while :;do sleep 3600;done");
} else if (appName == "xfce4-terminal") {
m_externalTerminal->start(appName, QStringList() << "-e" << " sh -c \"tty>" + file.fileName() + ";\"\"<&\\-\"\">&\\-;\"\"while :;\"\"do sleep 3600;\"\"done\"");
} else {
m_externalTerminal->start(appName, QStringList() << "-e" << "sh -c \"tty>" + file.fileName() + ";exec<&-;exec>&-;while :;do sleep 3600;done\"");
}
if (!m_externalTerminal->waitForStarted(500)) {
m_lastError = "Can't run terminal: " + appName;
m_externalTerminal->terminate();
return false;
}
for (int i = 0; i < 800; i++) {
if (!file.bytesAvailable()) {
if (m_externalTerminal->state() == QProcess::NotRunning && m_externalTerminal->exitCode()) {
break;
}
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
usleep(8000);
} else {
qCDebug(DEBUGGERCOMMON) << "Received terminal output(tty)";
break;
}
}
usleep(1000);
ttySlave = file.readAll().trimmed();
file.close();
if (ttySlave.isEmpty()) {
m_lastError = i18n("Can't receive %1 tty/pty. Check that %1 is actually a terminal and that it accepts these arguments: -e sh -c \"tty> %2 ;exec<&-;exec>&-;while :;do sleep 3600;done\"", appName, file.fileName());
}
return true;
}