本文整理汇总了C++中QDir::cdUp方法的典型用法代码示例。如果您正苦于以下问题:C++ QDir::cdUp方法的具体用法?C++ QDir::cdUp怎么用?C++ QDir::cdUp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDir
的用法示例。
在下文中一共展示了QDir::cdUp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setOpenFileName
/**
*Opens an open file dialog.
*/
QString DeviceWidget::setOpenFileName()
{
QFileDialog::Options options;
QString selectedFilter;
QString fwDirectoryStr;
QDir fwDirectory;
//Format filename for file chooser
#ifdef Q_OS_WIN
fwDirectoryStr=QCoreApplication::applicationDirPath();
fwDirectory=QDir(fwDirectoryStr);
fwDirectory.cdUp();
fwDirectory.cd("firmware");
fwDirectoryStr=fwDirectory.absolutePath();
#elif defined Q_OS_LINUX
fwDirectoryStr=QCoreApplication::applicationDirPath();
fwDirectory=QDir(fwDirectoryStr);
fwDirectory.cd("../../..");
fwDirectoryStr=fwDirectory.absolutePath();
fwDirectoryStr=fwDirectoryStr+"/fw_"+myDevice->lblBrdName->text().toLower()+"/fw_"+myDevice->lblBrdName->text().toLower()+".opfw";
#elif defined Q_OS_MAC
fwDirectoryStr=QCoreApplication::applicationDirPath();
fwDirectory=QDir(fwDirectoryStr);
fwDirectory.cd("../../../../../..");
fwDirectoryStr=fwDirectory.absolutePath();
fwDirectoryStr=fwDirectoryStr+"/fw_"+myDevice->lblBrdName->text().toLower()+"/fw_"+myDevice->lblBrdName->text().toLower()+".opfw";
#endif
QString fileName = QFileDialog::getOpenFileName(this,
tr("Select firmware file"),
fwDirectoryStr,
tr("Firmware Files (*.opfw *.bin)"),
&selectedFilter,
options);
return fileName;
}
示例2: GdbProcess
GdbProcess(const QString &program) : QProcess()
{
setProcessChannelMode(MergedChannels);
// don't attempt to load .gdbinit in home (may cause unexpected results)
QProcess::start("gdb", (QStringList() << "-nx" << (BINARY_PATH + '/' + program)));
const bool started = waitForStarted();
if (!started) {
qDebug() << "Failed to start 'gdb' executable:" << errorString();
Q_ASSERT(false);
return;
}
QByteArray prompt = waitForPrompt();
QVERIFY(!prompt.contains("No such file or directory"));
execute("set confirm off");
execute("set print pretty on");
execute("set disable-randomization off"); // see https://phabricator.kde.org/D2188
QList<QByteArray> p;
QDir printersDir = QFileInfo(__FILE__).dir();
printersDir.cdUp(); // go up to get to the main printers directory
p << "python"
<< "import sys"
<< "sys.path.insert(0, '"+printersDir.path().toLatin1()+"')"
<< "from qt import register_qt_printers"
<< "register_qt_printers (None)"
<< "from kde import register_kde_printers"
<< "register_kde_printers (None)"
<< "end";
foreach (const QByteArray &i, p) {
write(i + "\n");
}
示例3: workingCopy
QDir BazaarUtils::workingCopy(const QUrl& path)
{
QDir dir = BazaarUtils::toQDir(path);
while (!dir.exists(QStringLiteral(".bzr")) && dir.cdUp());
return dir;
}
示例4: on_calibButton_clicked
void AddCamera::on_calibButton_clicked()
{
QStringList arguments;
QString usbid = m_ui->usbId->text();
if(usbid == "")
{
usbid = "0";
}
arguments << usbid;
arguments << "-w" << "7" << "-h" << "5" << "-pt" << "chessboard" << "-n" << "25";
arguments << "-o" << m_ui->name->text() + ".yaml";
QDir dir = QDir::current();
dir.cdUp();
dir.cd("Calib");
QString path = dir.path() + "/Calib";
QFile file(path);
if(!file.exists())
{
qDebug() << "calib program does not exist in path:" << path;
}
m_calibApplication = new QProcess(this);
m_calibApplication->start(path, arguments);
connect(m_calibApplication, SIGNAL(finished(int)), this, SLOT(readYaml(int)));
}
示例5: remount
/**
* @brief Remount the file path,the mount point will be found automatically.
* @param file the path of file.
* @param mountType "rw" or "ro"
*/
bool RootTools::remount(QString file, QString mountType)
{
if(mounts_.size() == 0){
mounts_ = getMounts();
}
bool foundMount = false;
int i = 0;
QDir dir = QFileInfo(file).dir();
while(!foundMount){
for(i = 0; i < mounts_.size(); i++){
if(dir.absolutePath() == mounts_[i][1]){
foundMount = true;
break;
}
}
dir.cdUp();
if(dir.isRoot())
break;
}
if(!foundMount)
return false;
QString cmd = "mount -o " + mountType + ",remount " + mounts_[i][0] + " " + mounts_[i][1] + "\n";
qDebug()<<"mount"<<cmd;
shell_.write(cmd.toStdString().c_str(), cmd.size());
shell_.waitForBytesWritten(100);
return true;
}
示例6: file
bool
LibraryParser::serialize(QDir home)
{
// we write to root of all cyclists
home.cdUp();
// open file - truncate contents
QString filename = home.canonicalPath() + "/library.xml";
QFile file(filename);
file.open(QFile::WriteOnly);
file.resize(0);
QTextStream out(&file);
out.setCodec("UTF-8");
// write out to file
foreach (Library *l, ::libraries) {
// begin document
out << QString("<library name=\"%1\">\n").arg(l->name);
// paths...
foreach(QString p, l->paths)
out << QString("\t<path>%1</path>\n").arg(p);
// paths...
foreach(QString r, l->refs)
out << QString("\t<ref>%1</ref>\n").arg(r);
// end document
out << "</library>\n";
}
示例7: IExportImage
void QVaultImageNode::IExportImage()
{
plVaultImageNode* img = fNode.upcastToImageNode();
if (img == NULL)
return;
plVaultBlob blob = img->getImageData();
QString fname = fImgTitle->text() + ".jpg";
fname.replace(QRegExp("[\\\\/:*?\"<>|]"), "_");
if (!ieDir.isEmpty())
fname = ieDir + "/" + fname;
fname = QFileDialog::getSaveFileName(this, tr("Export JPEG"), fname,
"JPEG Files (*.jpg)", 0);
if (!fname.isEmpty()) {
QDir ieDirTmp = QDir(fname);
ieDirTmp.cdUp();
ieDir = ieDirTmp.absolutePath();
FILE* xf = fopen(fname.toUtf8().data(), "wb");
if (xf == NULL) {
QMessageBox::critical(this, tr("Error saving JPEG"),
tr("Could not open %1 for writing").arg(fname),
QMessageBox::Ok);
return;
}
fwrite((const uchar*)blob.getData() + 4, 1, blob.getSize() - 4, xf);
fclose(xf);
}
}
示例8: on_btnStart_clicked
void MainWindow::on_btnStart_clicked()
{
if (!QFile(programPath).exists()) {
QMessageBox::warning(this,
tr("Невозможно запустить процесс"),
tr("Не найден файл программы.\n"
"Возможно, не указан путь к файлу gostunnel.exe"));
return;
}
if (ui->lwGroups->count() == 0) {
return;
}
QString el = ui->lwGroups->currentItem()->text();
QProcess *proc = connections.value(el);
if (proc->pid() <= 0) {
QDir wd = QDir(programPath);
wd.cdUp();
proc->setWorkingDirectory(wd.path());
QStringList args;
args << "--config" << programConfig
<< "-s" << el;
connect(proc, SIGNAL(error(QProcess::ProcessError)),
this, SLOT(processError(QProcess::ProcessError)));
connect(proc, SIGNAL(finished(int,QProcess::ExitStatus)),
this, SLOT(processFinished(int,QProcess::ExitStatus)));
connect(proc, SIGNAL(stateChanged(QProcess::ProcessState)),
this, SLOT(processStateChenged(QProcess::ProcessState)));
connect(proc, SIGNAL(readyReadStandardError()),
this, SLOT(processReadyReadError()));
connect(proc, SIGNAL(started()),
this, SLOT(processStarted()));
ui->lwGroups->currentItem()->setBackgroundColor(QColor::fromRgb(255, 233, 113));
proc->start(programPath, args);
}
示例9: cdUp
void FileSystemModel::cdUp ()
{
QDir root (m_rootPath);
root.cdUp();
m_rootPath = root.absolutePath();
updateModel ();
}
示例10: init
void Config::init()
{
QDir path = QGuiApplication::applicationDirPath();
path.cdUp();
resourceDir = path.absolutePath() + "/Resources";
}
示例11: renameFolder
void FileSystemWidget::renameFolder()
{
QFileInfo info = contextFileInfo();
if (!info.isDir()) {
return;
}
QString folderName = QInputDialog::getText(m_liteApp->mainWindow(),
tr("Rename Folder"),tr("Folder Name"),
QLineEdit::Normal,info.fileName());
if (!folderName.isEmpty() && folderName != info.fileName()) {
QDir dir = contextDir();
dir.cdUp();
#ifdef Q_OS_WIN
QString _old = info.filePath();
QString _new = dir.path()+"/"+folderName;
if (!MoveFileW(_old.toStdWString().c_str(),_new.toStdWString().c_str())) {
QMessageBox::information(m_liteApp->mainWindow(),tr("Rename Folder"),
tr("Failed to rename the folder!"));
}
#else
if (!dir.rename(info.fileName(),folderName)) {
QMessageBox::information(m_liteApp->mainWindow(),tr("Rename Folder"),
tr("Failed to rename the folder!"));
}
#endif
}
}
示例12: selectResource
void QtResourceView::selectResource(const QString &resource)
{
QFileInfo fi(resource);
QDir dir = fi.absoluteDir();
if (fi.isDir())
dir = QDir(resource);
QString dirPath = dir.absolutePath();
QMap<QString, QTreeWidgetItem *>::const_iterator it;
while ((it = d_ptr->m_pathToItem.find(dirPath)) == d_ptr->m_pathToItem.constEnd()) {
if (!dir.cdUp())
break;
dirPath = dir.absolutePath();
}
if (it != d_ptr->m_pathToItem.constEnd()) {
QTreeWidgetItem *treeItem = it.value();
d_ptr->m_treeWidget->setCurrentItem(treeItem);
d_ptr->m_treeWidget->scrollToItem(treeItem);
// expand all up to current one is done by qt
// list widget is already propagated (currrent changed was sent by qt)
QListWidgetItem *item = d_ptr->m_resourceToItem.value(resource);
if (item) {
d_ptr->m_listWidget->setCurrentItem(item);
d_ptr->m_listWidget->scrollToItem(item);
}
}
}
示例13: fix_current_directory
bool fix_current_directory()
{
// First step, we need to find the "ca" directory. If we're running from a Mac
// bundle, then we'll need to walk up a few directories.
while (true) {
if (QDir("ca").exists())
return true;
// chdir to parent
QDir current = QDir::current();
current.cdUp();
// If we reached the top, then fatal.
if (current == QDir::current()) {
QMessageBox msg;
msg.setText("Fatal: Couldn't find the 'ca' directory");
msg.exec();
return false;
}
QDir::setCurrent(current.path());
}
}
示例14: main
int main(int argc, char *argv[])
{
// DECLARATIONS BEFORE APPLICATION STARTS
QApplication a(argc, argv);
QDir directory = QDir::current();
while(directory.dirName() != "Class-Project")
{
directory.cdUp();
}
if(!directory.cd("Database-Files"))
{
directory.mkpath("Database-Files");
directory.cd("Database-Files");
}
qDebug() << "Current Directory : " << directory.path();
QFile::copy(":/CustomerDatabase.txt",(directory.path() + "/CustomerList.txt"));
QFile::copy(":/ProductDatabase.txt",(directory.path() + "/ProductList.txt"));
QFile::copy(":/Testimonials.txt",(directory.path()) + "/Testimonials.txt");
// MAIN WINDOW HAS TO STAY DOWN HERE OR IT WILL TRY TO INITIALIZE BEFORE
// CHECKING FOR DIRECTORY
MainProgramWindow MainProgramWindow;
MainProgramWindow.setDatabaseStatus(false);
// DISPLAYS MAIN WINDOW
MainProgramWindow.show();
return a.exec();
}
示例15: cdUp
void FileBrowser::cdUp()
{
QDir dir = m_fileModel->rootDirectory();
if (!dir.path().isEmpty() && dir.cdUp()) {
addFolderToRoot(dir.path());
}
}