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


C++ QDir::homePath方法代码示例

本文整理汇总了C++中QDir::homePath方法的典型用法代码示例。如果您正苦于以下问题:C++ QDir::homePath方法的具体用法?C++ QDir::homePath怎么用?C++ QDir::homePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QDir的用法示例。


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

示例1: on_pushButtonRun_clicked

void IbcFile::on_pushButtonRun_clicked()
{
	QDir dir = QDir::home();
        QString home = dir.homePath();
        QString logFileName(home+"/log.html");
        ofstream log;
        log.open(qPrintable(logFileName), ios::out);
        log<<"<html><body><br><font size=3 color=black><p> Running... ";//</p></font></body></html>";
        log.close();
        ui->textBrowser->setSource(logFileName);
        ui->textBrowser->setFocus();
        ui->textBrowser->setModified(TRUE);
	
	//////
	fstream file;
	file.open(qPrintable(ui->lineEdit->text()), ios::out);
	file <<"0\t0\n0";
	file.close();
	//////

	log.open(qPrintable(logFileName), ios::app);
        log<<" Done!";
        log.close();
        ui->textBrowser->reload();
        QApplication::processEvents();
}
开发者ID:HydroCouple,项目名称:FVHMComponent,代码行数:26,代码来源:ibcfile.cpp

示例2: storeAuthorizedKeys

void Ssu::storeAuthorizedKeys(QByteArray data){
  QDir dir;
  SsuLog *ssuLog = SsuLog::instance();

  int uid_min = getdef_num("UID_MIN", -1);
  QString homePath;

  if (getuid() >= uid_min){
    homePath = dir.homePath();
  } else if (getuid() == 0){
    // place authorized_keys in the default users home when run with uid0
    struct passwd *pw = getpwuid(uid_min);
    if (pw == NULL){
      ssuLog->print(LOG_DEBUG, QString("Unable to find password entry for uid %1")
                    .arg(uid_min));
      return;
    }

    //homePath = QString(pw->pw_dir);
    homePath = pw->pw_dir;

    // use users uid/gid for creating the directories and files
    setegid(pw->pw_gid);
    seteuid(uid_min);
    ssuLog->print(LOG_DEBUG, QString("Dropping to %1/%2 for writing authorized keys")
                  .arg(uid_min)
                  .arg(pw->pw_gid));
  } else
    return;

  homePath = Sandbox::map(homePath);

  if (dir.exists(homePath + "/.ssh/authorized_keys")){
    ssuLog->print(LOG_DEBUG, QString(".ssh/authorized_keys already exists in %1")
                  .arg(homePath));
    restoreUid();
    return;
  }

  if (!dir.exists(homePath + "/.ssh"))
    if (!dir.mkdir(homePath + "/.ssh")){
      ssuLog->print(LOG_DEBUG, QString("Unable to create .ssh in %1")
                    .arg(homePath));
      restoreUid();
      return;
    }

  QFile::setPermissions(homePath + "/.ssh",
                        QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner);

  QFile authorizedKeys(homePath + "/.ssh/authorized_keys");
  authorizedKeys.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate);
  authorizedKeys.setPermissions(QFile::ReadOwner | QFile::WriteOwner);
  QTextStream out(&authorizedKeys);
  out << data;
  out.flush();
  authorizedKeys.close();

  restoreUid();
}
开发者ID:jvihrial,项目名称:ssu,代码行数:60,代码来源:ssu.cpp

示例3: folderButtonClicked

void WatchFolderAdd::folderButtonClicked() {
    QDir dir;
    fileDialog->setDirectory(dir.homePath()+"/");
    fileDialog->setFileMode(QFileDialog::DirectoryOnly);
    connect(fileDialog, SIGNAL(fileSelected(QString)), this, SLOT(folderSelected(QString)));
    fileDialog->exec();
}
开发者ID:JelF,项目名称:nixnote2,代码行数:7,代码来源:watchfolderadd.cpp

示例4: getInterfaceList

QStringList WSettings::getInterfaceList()
{
    //read interface.list
    QDir dir;
    QString config_path = dir.homePath()+"/.WifiAssist";
    QString interface_list_filename = config_path+"/interface.list";

    QStringList interface_list = QStringList();

    QFile inputFile(interface_list_filename);
    if(inputFile.open(QIODevice::ReadOnly))
    {
       QTextStream in(&inputFile);
       while (!in.atEnd())
       {
          QString line = in.readLine();
          interface_list << line;
       }
       inputFile.close();
    }
    else
    {
        QMessageBox::warning(NULL,"Warning","Can't find interface Record");
    }
    return interface_list;
}
开发者ID:bygreencn,项目名称:WifiAssist,代码行数:26,代码来源:wsettings.cpp

示例5: fileShareContentChanged

void NfcSharing::fileShareContentChanged(QString paths) {
	NfcShareFilesContent request;
    QList<QUrl> urls;
    QDir dir;

    QStringList list = paths.split(",");

    qDebug() << "XXXX Current Path" << dir.currentPath() << endl;
    qDebug() << "XXXX Home    Path" << dir.homePath() << endl;
    qDebug() << "XXXX Temp    Path" << dir.tempPath() << endl;

      QString publicPath(dir.currentPath().append("/app/public/"));

    for (int i = 0; i < list.size(); ++i) {

    	QUrl url(QString("file://").append(publicPath).append(list.at(i)));
        urls.append(url);

        QFileInfo fi(url.toLocalFile());

        qDebug() << "XXXX To Local File" << url.toLocalFile() << endl;
        qDebug() << "XXXX File String" << list.at(i) << endl;
        qDebug() << "XXXX File URL" << url << endl;
        qDebug() << "XXXX Absolute File Path" << fi.absoluteFilePath() << endl;
        qDebug() << "XXXX Absolute Path" << fi.absolutePath() << endl;
    }

    request.setFileUrls(urls);

    NfcShareSetContentError::Type rc = _nfcShareManager->setShareContent(request);

    qDebug() << "XXXX File setShareContent rc=" << rc << endl;
}
开发者ID:jaydeepw,项目名称:Cascades-Community-Samples,代码行数:33,代码来源:NfcSharing.cpp

示例6: write

void parseAPI::write(QNetworkReply* reply)
{
    if(!reply->isFinished()){
        qDebug()<<"error";
    }else{
        QDir dir;
        qDebug()<<dir.homePath()+name.toUtf8();
        QFile* file=new QFile(dir.homePath()+ QString("/Music/") + name + QString(".mp3"));
        file->open(QFile::Append);
        file->write(reply->readAll());
        if(file->flush()){
            qDebug()<<"success to save";
            file->close();
        }
        delete file;
        reply->deleteLater();
    }
}
开发者ID:SHIHUAMarryMe,项目名称:BDMusic,代码行数:18,代码来源:parseAPI.cpp

示例7: storeAuthorizedKeys

void Ssu::storeAuthorizedKeys(QByteArray data){
  QDir dir;

  // only set the key for unprivileged users
  if (getuid() < 1000) return;

  if (dir.exists(dir.homePath() + "/.ssh/authorized_keys"))
    return;

  if (!dir.exists(dir.homePath() + "/.ssh"))
    if (!dir.mkdir(dir.homePath() + "/.ssh")) return;

  QFile::setPermissions(dir.homePath() + "/.ssh",
                        QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner);

  QFile authorizedKeys(dir.homePath() + "/.ssh/authorized_keys");
  authorizedKeys.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate);
  authorizedKeys.setPermissions(QFile::ReadOwner | QFile::WriteOwner);
  QTextStream out(&authorizedKeys);
  out << data;
  out.flush();
  authorizedKeys.close();
}
开发者ID:lbt,项目名称:ssu,代码行数:23,代码来源:ssu.cpp

示例8: leerArchivo

void MainWindow::leerArchivo(){
    QDir directorio;
    QString dir = directorio.homePath();
    std::string home = dir.toStdString();

    QString nomArchivo = ui->boxArchivo->toPlainText();
    std::string nombreArchivo = nomArchivo.toStdString();

    std::string ruta = "";

    if (nombreArchivo.rfind(".txt") != -1) {
        ruta = home + "/Desktop/" + nombreArchivo;
    }
    else {
        ruta = home + "/Desktop/" + nombreArchivo + ".txt";
    }

    LectorArchivos lector;
    std::vector<int> datos = lector.leer(ruta);

    switch (currentArbol){
    case 1:{
        // Avl
        for(int i = 0; i < datos.size(); i++){
            NodoB<int> *nuevo = new NodoB<int>(datos[i]);
            avl->insert(nuevo);
        }
        break;
    }
    case 2:{
        //Rojinegro
        for(int i = 0; i < datos.size(); i++){
            NodoB<int> *nuevo = new NodoB<int>(datos[i]);
            rojinegro->RBinsert(nuevo);
        }
        break;
    }
    case 3:{
        //2/3
        for(int i = 0; i < datos.size(); i++){
            NodoDosTres<int>*nuevo = new NodoDosTres<int>(datos[i]);
            dosTres->insertar23(nuevo);
        }
        break;
    }
    }
}
开发者ID:javicuriel,项目名称:Protecto-Final,代码行数:47,代码来源:mainwindow.cpp

示例9: on_actionLoad_triggered

void MainWindow::on_actionLoad_triggered()
{
    QStringList fileName;
    QDir dir;
    QFileDialog *dialog = new QFileDialog(this,"Open File...", dir.homePath(), "CSV Files(*.csv)");
    dialog->setAcceptMode(QFileDialog::AcceptOpen);
    if(dialog->exec())
        fileName = dialog->selectedFiles();
    if (!fileName.isEmpty())
    {
        qDebug() << fileName.first();
        _amp->loadFromCSV(fileName.first());
    }
    else
        qDebug() << "No File Selected";
    delete(dialog);
}
开发者ID:Feirlane,项目名称:ampMeter,代码行数:17,代码来源:mainwindow.cpp

示例10: initialize

void Manitou::initialize()
{
    QCoreApplication::setApplicationName("Manitou");
    QCoreApplication::setApplicationVersion("0.1.0");
    QCoreApplication::setOrganizationName("Internet3D");
    QCoreApplication::setOrganizationDomain("internet3d.rdc.cz");

    // init database
    database.initialize();
    history = new History(this);
    searchHistory = new SearchHistory(this);

    // actions initialization
    createActions();

    // initialize Web icon ("favicon") cache database
    QString directory = QDesktopServices::storageLocation(QDesktopServices::CacheLocation);
    QDir dir;
    if (!directory.isEmpty()) {
        if (!dir.exists(directory)) {
            if (!dir.mkpath(directory)) {
                directory = "";
            }
        }
    }
    else {
        directory = dir.homePath() + "/." + QCoreApplication::applicationName();
        if (!dir.exists(directory)) {
            if (!dir.mkpath(directory)) {
                directory = "";
            }
        }
    }

    if (!directory.isEmpty()) {
        QWebSettings::setIconDatabasePath(directory);
    }

#ifdef Linux
    wiiRemote = new WiiRemote();
#endif

}
开发者ID:ddksaku,项目名称:manitou,代码行数:43,代码来源:Manitou.cpp

示例11: enableAutostart

void Settings::enableAutostart(bool enabled)
{
    if (enabled)
    {
        qDebug() << "@Settings: enable autostart";

        #ifdef Q_OS_LINUX
            QDir dir;

            if (!dir.exists(dir.homePath() + "/.config/autostart"))
                dir.mkdir(dir.homePath() + "/.config/autostart");
            if (!QFile::exists(dir.homePath() + "/.config/autostart/qtv.desktop"))
            {
                QFile file(dir.homePath() + "/.config/autostart/qtv.desktop");
                if (file.open(QIODevice::ReadWrite))
                {
                    file.write("[Desktop Entry]\n");
                    file.write(qPrintable("Version=" + QString(APPLICATION_VERSION) + "\n"));
                    file.write("Type=Application\n");
                    file.write(qPrintable("Name=" + QString(APPLICATION_NAME) + "\n"));
                    file.write("Comment=QT TV-Show Reminder\n");
                    file.write(qPrintable("Exec=" + QCoreApplication::applicationFilePath() + "\n"));
                    file.write(qPrintable("Icon=" + QCoreApplication::applicationDirPath() + "/icon.png"));
                    file.close();
                    system(qPrintable("chmod +x " + dir.homePath() + "/.config/autostart/qtv.desktop"));
                }
            }
        #elif defined Q_OS_WIN32
            QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat);
            settings.setValue("QTV", QCoreApplication::applicationFilePath());
        #else
            #error "QTV can't handle the autostart-settings for your system. Please refer to http://code.google.com/p/qtv/"
        #endif
    }
    else
    {
        qDebug() << "@Settings: disable autostart";

        #ifdef Q_OS_LINUX
            QDir dir;
            QFile::remove(dir.homePath() + "/.config/autostart/qtv.desktop");
        #elif defined Q_OS_WIN32
            QSettings settings("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat);
            settings.remove("QTV");
        #else
            #error "QTV can't handle the autostart-settings for your system. Please refer to http://code.google.com/p/qtv/"
        #endif
    }
}
开发者ID:lgeek,项目名称:QTV-fork,代码行数:49,代码来源:settings.cpp

示例12: checkInterfaceListFile

void WSettings::checkInterfaceListFile()
{
    //default config file "~/.WifiAssist/config.ini"
    //check is path exists
    QDir dir;
    QString config_path = dir.homePath()+"/.WifiAssist";

    dir.setPath(config_path);
    //if not exist,mkdir and Then set default config file.
    if(!dir.exists())
    {
        dir.mkdir(config_path);
    }


    //run net.sh to get interface list
    QString interface_list_filename = config_path+"/interface.list";
    QFile file;
    file.setFileName(interface_list_filename);

    if(!file.exists())
    {
        QStringList args = QStringList() << QCoreApplication::applicationDirPath()+"/bin/net.sh";
        QProcess qp;
        if(!qp.startDetached("bash",args))
        {
            QMessageBox::about(NULL,"Warning!","Can't Get Interface List");
        }

        QElapsedTimer t;
        t.start();
        while(t.elapsed()<2000)
            QCoreApplication::processEvents();
    }

}
开发者ID:bygreencn,项目名称:WifiAssist,代码行数:36,代码来源:wsettings.cpp

示例13: checkConfigFile

void WSettings::checkConfigFile()
{
    //default config file "~/.WifiAssist/config.ini"
    //check is path exists
    QDir dir;
    QString config_path = dir.homePath()+"/.WifiAssist";
    QString filename = config_path+"/config.ini";
    dir.setPath(config_path);
    //if not exist,mkdir and Then set default config file.
    if(!dir.exists())
    {
        dir.mkdir(config_path);
    }

    QFile file;
    file.setFileName(filename);
    if(!file.exists())
    {
        m_settings = new QSettings(filename,QSettings::IniFormat);
        setDefaultConfig();
    }
    else
        m_settings = new QSettings(filename,QSettings::IniFormat);
}
开发者ID:bygreencn,项目名称:WifiAssist,代码行数:24,代码来源:wsettings.cpp

示例14: getLocalHomeDir

QStringList FileSysAccess::getLocalHomeDir()
{
    QDir locDir;
    QString homeDir = locDir.homePath();
    return this->getFileSysList("", homeDir, false);
}
开发者ID:nixz,项目名称:covise,代码行数:6,代码来源:FileSysAccess.cpp

示例15: generate

void spatialPlotDlg::generate()
{
  QDir dir = QDir::home();
  QString home = dir.homePath();
  QString logFileName(home+"/log.html");
  ofstream log;
  log.open(qPrintable(logFileName), ios::out);
  log<<"<html><body><br><font size=3 color=black><p> Running... ";      //</p></font></body></html>";
  log.close();
  textBrowser->setSource(logFileName);
  textBrowser->setFocus();
  textBrowser->setModified(TRUE);
  QApplication::processEvents();

  QgsProject *p = QgsProject::instance();
  QString projDir = p->readPath(p->readEntry("pihm", "projDir"));

  int bins;
  double **avgVal;

  int tabIndex;
  int variableIndex;
  int startTime, finishTime;
  int NUM_STEPS;
  int dataCount = 0;
  char fStr[100];

  int runFlag = 1;
  QString shapeFileName, outputFileName;
  ifstream inStream, inStream2;

  int NUM_ELE = 0;
  int NUM_RIV = 0;

  tabIndex = tabWidget->currentIndex();
  if(tabIndex == ELEMENT_FEATURE)
  {
    variableIndex = comboBoxEleVariable->currentIndex();
    startTime  = ( lineEditEleStart->text() ).toInt();
    finishTime = ( lineEditEleFinish->text() ).toInt();

    bins = lineEditBinsEle->text().toInt();
    int units = comboBoxEle->currentIndex();
    units = units==0 ? 1 : units==1 ? 60 : 1440;           // how many minutes
    // intercep, sat, unsat, surf, evap, trans, evap gw/sw, prep ??, nprep ??, infil ??, rech
    //                  106, 101, 107, 102, 108, 108, 108, 101, 101, 101, 105
    const int index[] = {5, 0, 6, 1, 7, 7, 7, 0, 0, 0, 4};
    QString var("step%1");
    int steps = p->readNumEntry("pihm", var.arg(index[comboBoxEleVariable->currentIndex()]));

    startTime = startTime*units / steps; cout << "Start Row= "<<startTime<<"\n";
    finishTime= finishTime*units/ steps; cout << "FinishRow= "<<finishTime<<"\n";

    shapeFileName  = lineEditEleShape->text();
    outputFileName = lineEditFileName->text();

    NUM_STEPS = finishTime - startTime + 1;
    cout<<"NUM_STEPS= "<<NUM_STEPS<<"\n";
    //getchar(); getchar();
    if( outputFileName.endsWith("txt", Qt::CaseInsensitive) ) {
      inStream.open( qPrintable(outputFileName) );
      if(inStream == NULL) {
        QMessageBox::critical(this, "Couldn't Open File", outputFileName);
        return;
        //exit(1);
      }
      string str;
      getline(inStream, str);
      int pos = 0;
      while( (pos = str.find('\t', pos+1) ) != -1 ) {
        NUM_ELE++;
      }
      cout << "NUM_ELE= "<<NUM_ELE<<"\n";
      inStream.close();
      inStream.open(qPrintable(outputFileName));
      avgVal = (double **)malloc(bins * sizeof(double *));
      for(int i=0; i<bins; i++) {
        avgVal[i] = (double *)malloc(NUM_ELE * sizeof(double));
        for(int j=0; j<NUM_ELE; j++)
          avgVal[i][j] = 0.0;
      }

      for(int i=1; i<startTime; i++)
        getline(inStream, str);
      if(inStream == NULL) {
        qWarning("Error: File ended Prematurely!\n       Cannot parse \"Start Time\" provided.\n");
        runFlag = 0;
      }
      if(runFlag != 0) {
        double temp;
        for(int b=0; b<bins; b++) {
          for(int i=0; i<NUM_STEPS/bins; i++) {
            if(inStream) {
              for(int j=0; j<NUM_ELE; j++) {
                inStream >> temp;
                avgVal[b][j]+=temp;
              }
              dataCount++;
            }
            else{
//.........这里部分代码省略.........
开发者ID:mlt,项目名称:PIHM,代码行数:101,代码来源:spatialplot.cpp


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