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


C++ QProgressBar::value方法代码示例

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


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

示例1: filterView

void CalculateAmplitudes::filterView(int startRow, int cnt) {
    bool showSuccess = _ui.comboFilterState->currentIndex() == 1;
    bool showErrors = _ui.comboFilterState->currentIndex() == 2;
    bool showProgress = _ui.comboFilterState->currentIndex() == 3;

    QString type = _ui.comboFilterType->currentIndex() == 0?"":_ui.comboFilterType->currentText();

    int endRow;
    if ( cnt < 0 )
        endRow = _ui.table->rowCount();
    else
        endRow = startRow + cnt;

    for ( int i = startRow; i < endRow; ++i ) {
        bool hide = false;

        if ( showSuccess ) {
            QProgressBar *progressBar = static_cast<QProgressBar*>(_ui.table->cellWidget(i, 3));
            QTableWidgetItem *item = _ui.table->item(i, 3);
            if ( progressBar != NULL && progressBar->value() < 100 )
                hide = true;
            else if ( item && item->data(Qt::UserRole) == 1 )
                hide = true;
        }

        if ( showErrors ) {
            QTableWidgetItem *item = _ui.table->item(i, 3);
            if ( _ui.table->cellWidget(i, 3) != NULL ||
                    (item && item->data(Qt::UserRole) != 1) )
                hide = true;
        }

        if ( showProgress ) {
            QProgressBar *progressBar = static_cast<QProgressBar*>(_ui.table->cellWidget(i, 3));
            QTableWidgetItem *item = _ui.table->item(i, 3);
            if ( progressBar == NULL || progressBar->value() == 100 )
                hide = true;
            else if ( item && item->data(Qt::UserRole) == 1 )
                hide = true;
        }

        if ( !type.isEmpty() ) {
            if ( _ui.table->item(i, 1)->text() != type )
                hide = true;
        }

        if ( hide )
            _ui.table->hideRow(i);
        else
            _ui.table->showRow(i);
    }
}
开发者ID:peacocks,项目名称:seiscomp3,代码行数:52,代码来源:calculateamplitudes.cpp

示例2: timeOut

void ConnectionChecker::timeOut()
{
	i++;
	if( i > 5000 )
	{
		ui->statusLabel->setText( "No Data Recieved, Change Port" );
		timer->stop();
	}
	QProgressBar* bar = ui->statusBar;
	bar->setValue(bar->value()+1);
	if( bar->value() > 99 )
		bar->setValue(0);
}
开发者ID:dangrie158,项目名称:WakingWind,代码行数:13,代码来源:connectionchecker.cpp

示例3: fillFromJson

void dataBase::fillFromJson(const QString &path)
{
    QProgressBar bar;
    bar.show();
    QFile file(path);
    if(!file.open(QFile::ReadOnly))
    {
        throw std::runtime_error(("No file "+ path).toStdString());
    }
    bool ok = false;
    QVariantMap map = QtJson::parse(QString::fromUtf8(file.readAll().data()), ok).toMap();
    if(!ok)
    {
        throw std::runtime_error(("Cant parse "+ path).toStdString());
    }
    for(QVariantMap::const_iterator it = map.begin(); it != map.end(); ++it)
    {
        QList<QVariant> list = it.value().toList();
        for(QList<QVariant>::const_iterator list_it = list.begin(); list_it != list.end(); ++list_it)
        {
            bar.setValue(bar.value() >= bar.maximum() ? 0 : bar.value()+1);
            qApp->processEvents();
            QList<QVariant> values = list_it->toList();
            QString q_text = QString("INSERT INTO %1 ( coeff, hrn  ) VALUES ( '%2', '%3' )")
                    .arg(it.key())
                    .arg(values.at(0).toString())
                    .arg(values.at(1).toString());

            query(q_text);
        }
    }
    QList<QVariant> regions = map["regions"].toList();
    for(QList<QVariant>::const_iterator it = regions.begin(); it!= regions.end(); ++it )
    {
        QList<QVariant> towns = it->toList().at(2).toList();
        for(QList<QVariant>::const_iterator town_it = towns.begin(); town_it != towns.end(); ++town_it )
        {
            bar.setValue(bar.value() >= bar.maximum() ? 0 : bar.value()+1);
            qApp->processEvents();
            QList<QVariant> town_desc = town_it->toList();
            QString q_text = QString("INSERT INTO towns VALUES ( %1, '%2', %3, %4, %5)")
                    .arg(town_desc.at(0).toInt())
                    .arg(town_desc.at(1).toString())
                    .arg(town_desc.at(2).toString())
                    .arg(town_desc.at(3).toString())
                    .arg(it->toList().at(0).toInt());
            query(q_text);
        }
    }
    bar.close();
}
开发者ID:ruslanfirefly,项目名称:CalcKaskoAsko,代码行数:51,代码来源:database.cpp

示例4: setValue

/**
 * Sets a new value to the progress bar.
 * If the new value is non-zero, the progress bar is advanced. Otherwise, the
 * idle timer is initiated to display a busy indicator.
 * @param	nValue	The new value to set.
 */
void ProgressDlg::setValue(int nValue)
{
	QProgressBar* pProgress;

	pProgress = progressBar();
	
	if (nValue != 0) {
		// Do nothing if the value hasn't changed
		if (nValue == pProgress->value())
			return;

		// Handle first non-zero value
		if (m_nIdleValue >= 0) {
			m_pIdleTimer->stop();
			m_nIdleValue = -1;
			pProgress->setTextVisible(true);
		}

		// Set the new value
		pProgress->setValue(nValue);
	}
	else if (m_nIdleValue == -1) {
		// Handle first 0 value
		pProgress->setValue(0);
		pProgress->setTextVisible(false);
		m_nIdleValue = 0;
		m_pIdleTimer->start(200);
	}
}
开发者ID:choueric,项目名称:kscope-4,代码行数:35,代码来源:progressdlg.cpp

示例5: slotImportJobDone

void XXPortManager::slotImportJobDone( KJob * )
{
  if ( !mImportProgressDialog ) {
    return;
  }

  QProgressBar *progressBar = mImportProgressDialog->progressBar();

  progressBar->setValue( progressBar->value() + 1 );

  // cleanup on last step
  if ( progressBar->value() == progressBar->maximum() ) {
    mImportProgressDialog->deleteLater();
    mImportProgressDialog = 0;
  }
}
开发者ID:chusopr,项目名称:kdepim-ktimetracker-akonadi,代码行数:16,代码来源:xxportmanager.cpp

示例6: backup

void BackupDialog::backup()
{
    QDir dir;

    // Compute a default file name & path (eg. "Baskets_2007-01-31.tar.gz"):
    KConfig *config = KGlobal::config().data();
    KConfigGroup configGroup(config, "Backups");
    QString folder = configGroup.readEntry("lastFolder", QDir::homePath()) + "/";
    QString fileName = i18np("Backup filename (without extension), %1 is the date", "Baskets_%1", QDate::currentDate().toString(Qt::ISODate));
    QString url = folder + fileName;

    // Ask a file name & path to the user:
    QString filter = "*.tar.gz|" + i18n("Tar Archives Compressed by Gzip") + "\n*|" + i18n("All Files");
    QString destination = url;
    for (bool askAgain = true; askAgain;) {
        // Ask:
        destination = KFileDialog::getSaveFileName(destination, filter, 0, i18n("Backup Baskets"));
        // User canceled?
        if (destination.isEmpty())
            return;
        // File already existing? Ask for overriding:
        if (dir.exists(destination)) {
            int result = KMessageBox::questionYesNoCancel(
                             0,
                             "<qt>" + i18n("The file <b>%1</b> already exists. Do you really want to override it?",
                                           KUrl(destination).fileName()),
                             i18n("Override File?"),
                             KGuiItem(i18n("&Override"), "document-save")
                         );
            if (result == KMessageBox::Cancel)
                return;
            else if (result == KMessageBox::Yes)
                askAgain = false;
        } else
            askAgain = false;
    }

    KProgressDialog dialog(0, i18n("Backup Baskets"), i18n("Backing up baskets. Please wait..."));
    dialog.setModal(true);
    dialog.setAllowCancel(false);
    dialog.setAutoClose(true);
    dialog.show();
    QProgressBar *progress = dialog.progressBar();
    progress->setRange(0, 0/*Busy/Undefined*/);
    progress->setValue(0);
    progress->setTextVisible(false);

    BackupThread thread(destination, Global::savesFolder());
    thread.start();
    while (thread.isRunning()) {
        progress->setValue(progress->value() + 1); // Or else, the animation is not played!
        kapp->processEvents();
        usleep(300); // Not too long because if the backup process is finished, we wait for nothing
    }

    Settings::setLastBackup(QDate::currentDate());
    Settings::saveConfig();
    populateLastBackup();
}
开发者ID:KrissN,项目名称:basket,代码行数:59,代码来源:backup.cpp

示例7: inc_progress_bar

void inc_progress_bar(int, int, void *p)
{
	QProgressBar *bar = (QProgressBar *)p;
	int value = bar->value();

	if (value == bar->maximum()) {
		bar->reset();
	} else {
		bar->setValue(value +1);
	}
}
开发者ID:jbfavre,项目名称:xca,代码行数:11,代码来源:func.cpp

示例8: execFinished

ProgressUI::ProgressUI(QWidget *parent)
    : THWidgetBase(parent)
{
    timerId = -1;
    gradient = 0;
    hideTitleBar();
    setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Tool);
    setWindowModality(Qt::ApplicationModal);

    QVBoxLayout *v = new QVBoxLayout(this);
    v->setContentsMargins(5, 5, 5, 5);
    v->setSpacing(0);
    lbl = new QLabel(this);
    lbl->setStyleSheet(QStringLiteral("font-family:΢ÈíÑźÚ;font:12px;color:white;"));
    QProgressBar *pbar = new QProgressBar(this);
    pbar->setRange(0, 100);
    pbar->setValue(0);
    pbar->setFixedSize(260, 12);
    QFile file;
    file.setFileName(":res/css/progressbar.css");
    if (file.open(QIODevice::ReadOnly))
    {
        QByteArray ba = file.readAll();
        pbar->setStyleSheet(QTextCodec::codecForLocale()->toUnicode(ba));
    }
    file.close();
    v->addWidget(lbl, 1, Qt::AlignCenter);
    v->addWidget(pbar, 1, Qt::AlignCenter);
    setFixedSize(280, 50);

    connect(this, &ProgressUI::setValue, pbar, [=] (int value) {
        pbar->setValue(value);
        if (pbar->value() >= 100)
        {
            lbl->setText(QStringLiteral("Íê³É"));
            emit execFinished();
            QTimer::singleShot(1000, this, [=] () {
                disconnect(this, 0, 0, 0);
                this->close();
                this->deleteLater();
            });
        }
    });

    timerId = startTimer(60/*, Qt::VeryCoarseTimer*/);


}
开发者ID:AlanHJ,项目名称:TogetherHappy,代码行数:48,代码来源:progressui.cpp

示例9: main

int main(int argc, char **argv)
{
    int p = 0;

    toConfigurationNew::setQSettingsEnv();

    QApplication app(argc, argv);

    qRegisterMetaType<toQColumnDescriptionList>("toQColumnDescriptionList&");
    qRegisterMetaType<ValuesList>("ValuesList&");
    qRegisterMetaType<toConnection::exception>("toConnection::exception");

    try
    {
        toSplash splash(NULL);
        splash.show();

        QList<QString> plugins;

        // List of all connection provider finders
        std::vector<std::string> finders = ConnectionProviderFinderFactory::Instance().keys();
        // Resulting list of all the providers found
        toProvidersList &allProviders = toProvidersListSing::Instance();

        QProgressBar *progress = splash.progress();
        QLabel *label = splash.label();
        progress->setRange(1, plugins.size() + finders.size()*2);
        qApp->processEvents();
        Q_FOREACH(QString path, plugins)
        {
            label->setText(qApp->translate("main", "Loading plugin %1").arg(path));
            qApp->processEvents();
            bool success = false;
            try
            {
                QLibrary library(path);
                success = library.load();
            }
            TOCATCH;

            if (success)
            {
                label->setText(qApp->translate("main", "Loaded plugin %1").arg(path));
                TLOG(5, toDecoratorNC, __HERE__) << "Loaded plugin " << path << std::endl;
            }
            else
            {
                label->setText(qApp->translate("main", "Failed loading plugin %1").arg(path));
                TLOG(5, toDecoratorNC, __HERE__) << "Failed loading plugin " << path << std::endl;
            }
            progress->setValue(progress->value()+1);
            qApp->processEvents();
        }

        // Loop over all finders and call their "find" method, each of them can return several locations
        for (std::vector<std::string>::const_iterator i = finders.begin(); i != finders.end(); ++i)
        {
            QString finderName(i->c_str());
            label->setText(qApp->translate("main", "Looking for %1").arg(finderName));
            qApp->processEvents();
            TLOG(5, toDecoratorNC, __HERE__) << "Looking for client: " << *i << std::endl;
            try
            {
                std::unique_ptr<toConnectionProviderFinder> finder = ConnectionProviderFinderFactory::Instance().create(*i, 0);
                QList<toConnectionProviderFinder::ConnectionProvirerParams> l = finder->find();
                allProviders.append(l);
                finderName = finder->name();
            }
            TOCATCH;
            progress->setValue(progress->value()+1);
            qApp->processEvents();
        }

        // Loop over all providers found and try to load desired Oracle client
        // 1st try to load requested Oracle client(if set) then load thick(TNS) Oracle client
        QDir oHome = toConfigurationNewSingle::Instance().option(ToConfiguration::Global::OracleHomeDirectory).toString();
        Q_FOREACH(toConnectionProviderFinder::ConnectionProvirerParams const& params, allProviders)
        {
            QString providerName = params.value("PROVIDER").toString();
            if ( params.value("PROVIDER").toString() != ORACLE_PROVIDER)
                continue;
            QDir pHome(params.value("ORACLE_HOME").toString());
            if (oHome != pHome)
                continue;
            try
            {
                label->setText(qApp->translate("main", "Loading provider %1").arg(providerName));
                qApp->processEvents();
                TLOG(5, toDecoratorNC, __HERE__) << "Loading: " << params.value("PATH").toString() << std::endl;
                toConnectionProviderRegistrySing::Instance().load(params);
                progress->setValue(progress->value()+1);
                qApp->processEvents();
                break;
            }
            TOCATCH;
        }
开发者ID:Daniel1892,项目名称:tora,代码行数:96,代码来源:test5.cpp

示例10: generateEditorWithQrmc

void MetaEditorSupportPlugin::generateEditorWithQrmc()
{
    qrmc::MetaCompiler metaCompiler(*mLogicalRepoApi, ".");

    IdList const metamodels = mLogicalRepoApi->children(Id::rootId());

    QProgressBar *progress = new QProgressBar(mMainWindowInterface->windowWidget());
    progress->show();
    int const progressBarWidth = 240;
    int const progressBarHeight = 20;

    QApplication::processEvents();
    QRect const screenRect = qApp->desktop()->availableGeometry();
    progress->move(screenRect.width() / 2 - progressBarWidth / 2, screenRect.height() / 2 - progressBarHeight / 2);
    progress->setFixedWidth(progressBarWidth);
    progress->setFixedHeight(progressBarHeight);
    progress->setRange(0, 100);

    int forEditor = 60 / metamodels.size();

    foreach (Id const &key, metamodels) {
        QString const objectType = key.element();
        if (objectType == "MetamodelDiagram" && mLogicalRepoApi->isLogicalElement(key)) {
            QString nameOfTheDirectory = mLogicalRepoApi->stringProperty(key, "name of the directory");
            QString nameOfMetamodel = mLogicalRepoApi->stringProperty(key, "name");
            QString nameOfPlugin = nameOfTheDirectory.split("/").last();

            if (QMessageBox::question(mMainWindowInterface->windowWidget()
                                      , tr("loading..")
                                      , QString(tr("Do you want to compile and load editor %1?")).arg(nameOfPlugin)
                                      , QMessageBox::Yes, QMessageBox::No)
                    == QMessageBox::No)
            {
                continue;
            }

            progress->setValue(5);

            const QString normalizedName = nameOfMetamodel.at(0).toUpper() + nameOfMetamodel.mid(1);
            const bool stateOfLoad = mMainWindowInterface->pluginLoaded(normalizedName);
            if (!mMainWindowInterface->unloadPlugin(normalizedName)) {
                progress->close();
                delete progress;
                return;
            }

            if (!metaCompiler.compile(nameOfMetamodel)) { // generating source code for all metamodels
                QMessageBox::warning(mMainWindowInterface->windowWidget()
                                     , tr("error")
                                     , tr("Cannot generate source code for editor ") + nameOfPlugin);
                continue;
            }
            progress->setValue(20);

            QStringList qmakeArgs;
            qmakeArgs.append("CONFIG+=" + mLogicalRepoApi->stringProperty(key, "buildConfiguration"));
            qmakeArgs.append(nameOfMetamodel + ".pro");

            QProcess builder;
            builder.setWorkingDirectory(nameOfTheDirectory);
            const QStringList environment = QProcess::systemEnvironment();
            builder.setEnvironment(environment);
            builder.start(SettingsManager::value("pathToQmake").toString(), qmakeArgs);

            qDebug()  << "qmake";
            if ((builder.waitForFinished()) && (builder.exitCode() == 0)) {
                progress->setValue(40);
                builder.start(SettingsManager::value("pathToMake").toString());

                bool finished = builder.waitForFinished(100000);
                qDebug()  << "make";

                if (finished && (builder.exitCode() == 0)) {
                    if (stateOfLoad) {
                        QMessageBox::warning(mMainWindowInterface->windowWidget()
                                             , tr("Attention!"), tr("Please restart QReal."));
                        progress->close();
                        delete progress;
                        return;
                    }
                    qDebug()  << "make ok";
                    progress->setValue(progress->value() + forEditor / 2);

                    if (!nameOfMetamodel.isEmpty()) {
                        if (!mMainWindowInterface->unloadPlugin(normalizedName)) {
                            QMessageBox::warning(mMainWindowInterface->windowWidget()
                                                 , tr("error")
                                                 , tr("cannot unload plugin ") + normalizedName);
                            progress->close();
                            delete progress;
                            continue;
                        }
                    }

                    QString suffix = "";
                    if (mLogicalRepoApi->stringProperty(key, "buildConfiguration") == "debug") {
                        suffix = "-d";
                    }

                    QString const generatedPluginFileName = SettingsManager::value("prefix").toString()
//.........这里部分代码省略.........
开发者ID:qreal,项目名称:qreal,代码行数:101,代码来源:metaEditorSupportPlugin.cpp

示例11: restore

void BackupDialog::restore()
{
    // Get last backup folder:
    KConfig *config = KGlobal::config().data();
    KConfigGroup configGroup(config, "Backups");
    QString folder = configGroup.readEntry("lastFolder", QDir::homePath()) + "/";

    // Ask a file name to the user:
    QString filter = "*.tar.gz|" + i18n("Tar Archives Compressed by Gzip") + "\n*|" + i18n("All Files");
    QString path = KFileDialog::getOpenFileName(folder, filter, this, i18n("Open Basket Archive"));
    if (path.isEmpty()) // User has canceled
        return;

    // Before replacing the basket data folder with the backup content, we safely backup the current baskets to the home folder.
    // So if the backup is corrupted or something goes wrong while restoring (power cut...) the user will be able to restore the old working data:
    QString safetyPath = Backup::newSafetyFolder();
    FormatImporter copier;
    copier.moveFolder(Global::savesFolder(), safetyPath);

    // Add the README file for user to cancel a bad restoration:
    QString readmePath = safetyPath + i18n("README.txt");
    QFile file(readmePath);
    if (file.open(QIODevice::WriteOnly)) {
        QTextStream stream(&file);
        stream << i18n("This is a safety copy of your baskets like they were before you started to restore the backup %1.", KUrl(path).fileName()) + "\n\n"
        << i18n("If the restoration was a success and you restored what you wanted to restore, you can remove this folder.") + "\n\n"
        << i18n("If something went wrong during the restoration process, you can re-use this folder to store your baskets and nothing will be lost.") + "\n\n"
        << i18n("Choose \"Basket\" -> \"Backup & Restore...\" -> \"Use Another Existing Folder...\" and select that folder.") + "\n";
        file.close();
    }

    QString message =
        "<p><nobr>" + i18n("Restoring <b>%1</b>. Please wait...", KUrl(path).fileName()) + "</nobr></p><p>" +
        i18n("If something goes wrong during the restoration process, read the file <b>%1</b>.", readmePath);

    KProgressDialog *dialog = new KProgressDialog(0, i18n("Restore Baskets"), message);
    dialog->setModal(/*modal=*/true);
    dialog->setAllowCancel(false);
    dialog->setAutoClose(true);
    dialog->show();
    QProgressBar *progress = dialog->progressBar();
    progress->setRange(0, 0/*Busy/Undefined*/);
    progress->setValue(0);
    progress->setTextVisible(false);

    // Uncompress:
    RestoreThread thread(path, Global::savesFolder());
    thread.start();
    while (thread.isRunning()) {
        progress->setValue(progress->value() + 1); // Or else, the animation is not played!
        kapp->processEvents();
        usleep(300); // Not too long because if the restore process is finished, we wait for nothing
    }

    dialog->hide(); // The restore is finished, do not continue to show it while telling the user the application is going to be restarted
    delete dialog; // If we only hidden it, it reappeared just after having restored a small backup... Very strange.
    dialog = 0;    // This was annoying since it is modal and the "BasKet Note Pads is going to be restarted" message was not reachable.
    //kapp->processEvents();

    // Check for errors:
    if (!thread.success()) {
        // Restore the old baskets:
        QDir dir;
        dir.remove(readmePath);
        copier.moveFolder(safetyPath, Global::savesFolder());
        // Tell the user:
        KMessageBox::error(0, i18n("This archive is either not a backup of baskets or is corrupted. It cannot be imported. Your old baskets have been preserved instead."), i18n("Restore Error"));
        return;
    }

    // Note: The safety backup is not removed now because the code can has been wrong, somehow, or the user perhapse restored an older backup by error...
    //       The restore process will not be called very often (it is possible it will only be called once or twice arround the world during the next years).
    //       So it is rare enough to force the user to remove the safety folder, but keep him in control and let him safely recover from restoration errors.

    Backup::setFolderAndRestart(Global::savesFolder()/*No change*/, i18n("Your backup has been successfuly restored to <b>%1</b>. %2 is going to be restarted to take this change into account."));
}
开发者ID:KrissN,项目名称:basket,代码行数:76,代码来源:backup.cpp

示例12: createWidget


//.........这里部分代码省略.........
        menu1->addMenu("Menu2");
        parentMenu->addSeparator();
        parentMenu->addMenu("Menu3");
        return setLayoutWidget({ parentMenu }, { 160, 110 });
    }
    else if(name == "MenuBar")
    {
        QMenuBar* bar = new QMenuBar;
        bar->setObjectName("QMenuBar");
        QMenu* menu1 = bar->addMenu("MenuBar1");
        menu1->addMenu("Menu1");
        menu1->addSeparator();
        menu1->addMenu("Menu2");
        QMenu* menu2 = bar->addMenu("MenuBar2");
        menu2->addMenu("Menu1");
        menu2->addSeparator();
        menu2->addMenu("Menu2");
        QMenu* menu3 = bar->addMenu("MenuBar3");
        menu3->addMenu("Menu1");
        menu3->addSeparator();
        menu3->addMenu("Menu2");
        return setLayoutWidget({ bar }, { 280, 60 });
    }
    else if(name == "ProgressBar")
    {
        QProgressBar* bar = new QProgressBar;
        bar->setObjectName("ProgressBar");
        bar->setRange(0, 100);
        bar->setValue(0);

        QTimer* timer = new QTimer(bar);
        this->connect(timer, &QTimer::timeout, this, [bar]()
        {
            if(bar->value() == 100)
                bar->setValue(0);
            else
                bar->setValue(bar->value() + 1);
        });
        timer->start(100);
        return setLayoutWidget({ bar }, { 110, 30 });
    }
    else if(name == "PushButton")
    {
        QPushButton* button = new QPushButton("PushButton");
        button->setObjectName("PushButton");
        return setLayoutWidget({ button }, { 125, 30 });
    }
    else if(name == "RadioButton")
    {
        QRadioButton* button = new QRadioButton("RadioButton");
        button->setObjectName("RadioButton");
        return setLayoutWidget({ button }, { 125, 30 });
    }
    else if(name == "ScrollBar")
    {
        QScrollBar* barH = new QScrollBar(Qt::Horizontal);
        QScrollBar* barV = new QScrollBar(Qt::Vertical);
        barH->setObjectName("ScrollBarH");
        barV->setObjectName("ScrollBarV");
        return setLayoutWidget({ barH, barV }, { 200, 100 });
    }
    else if(name == "Slider")
    {
        QSlider* sliderH = new QSlider(Qt::Horizontal);
        QSlider* sliderV = new QSlider(Qt::Vertical);
        sliderH->setObjectName("SliderH");
开发者ID:kissofblood,项目名称:September,代码行数:67,代码来源:widgetstyle.cpp

示例13: save

void Archive::save(Basket *basket, bool withSubBaskets, const QString &destination)
{
	QDir dir;
	KProgressDialog dialog(0, i18n("Save as Basket Archive"), i18n("Saving as basket archive. Please wait..."), /*Not modal, for password dialogs!*/false);
	dialog.showCancelButton(false);
	dialog.setAutoClose(true);
	dialog.show();
	QProgressBar *progress = dialog.progressBar();
    
    progress->setRange(0,/*Preparation:*/1 + /*Finishing:*/1 + /*Basket:*/1 + /*SubBaskets:*/(withSubBaskets ? Global::bnpView->basketCount(Global::bnpView->listViewItemForBasket(basket)) : 0));
	progress->setValue(0);

	// Create the temporary folder:
	QString tempFolder = Global::savesFolder() + "temp-archive/";
	dir.mkdir(tempFolder);

	// Create the temporary archive file:
	QString tempDestination = tempFolder + "temp-archive.tar.gz";
	KTar tar(tempDestination, "application/x-gzip");
	tar.open(QIODevice::WriteOnly);
	tar.writeDir("baskets", "", "");

    progress->setValue(progress->value()+1);        // Preparation finished
    
	kDebug() << "Preparation finished out of " << progress->maximum();

	// Copy the baskets data into the archive:
	QStringList backgrounds;
	Archive::saveBasketToArchive(basket, withSubBaskets, &tar, backgrounds, tempFolder, progress);

	// Create a Small baskets.xml Document:
	QDomDocument document("basketTree");
	QDomElement root = document.createElement("basketTree");
	document.appendChild(root);
	Global::bnpView->saveSubHierarchy(Global::bnpView->listViewItemForBasket(basket), document, root, withSubBaskets);
	Basket::safelySaveToFile(tempFolder + "baskets.xml", "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" + document.toString());
	tar.addLocalFile(tempFolder + "baskets.xml", "baskets/baskets.xml");
	dir.remove(tempFolder + "baskets.xml");

	// Save a Small tags.xml Document:
	QList<Tag*> tags;
	listUsedTags(basket, withSubBaskets, tags);
	Tag::saveTagsTo(tags, tempFolder + "tags.xml");
	tar.addLocalFile(tempFolder + "tags.xml", "tags.xml");
	dir.remove(tempFolder + "tags.xml");

	// Save Tag Emblems (in case they are loaded on a computer that do not have those icons):
	QString tempIconFile = tempFolder + "icon.png";
	for (Tag::List::iterator it = tags.begin(); it != tags.end(); ++it) {
		State::List states = (*it)->states();
		for (State::List::iterator it2 = states.begin(); it2 != states.end(); ++it2) {
			State *state = (*it2);
			QPixmap icon = KIconLoader::global()->loadIcon(
                state->emblem(), KIconLoader::Small, 16, KIconLoader::DefaultState,
                QStringList(), 0L, true
                );
			if (!icon.isNull()) {
				icon.save(tempIconFile, "PNG");
				QString iconFileName = state->emblem().replace('/', '_');
				tar.addLocalFile(tempIconFile, "tag-emblems/" + iconFileName);
			}
		}
	}
	dir.remove(tempIconFile);

	// Finish Tar.Gz Exportation:
	tar.close();

	// Computing the File Preview:
	Basket *previewBasket = basket; // FIXME: Use the first non-empty basket!
	QPixmap previewPixmap(previewBasket->visibleWidth(), previewBasket->visibleHeight());
	QPainter painter(&previewPixmap);
	// Save old state, and make the look clean ("smile, you are filmed!"):
	NoteSelection *selection = previewBasket->selectedNotes();
	previewBasket->unselectAll();
	Note *focusedNote = previewBasket->focusedNote();
	previewBasket->setFocusedNote(0);
	previewBasket->doHoverEffects(0, Note::None);
	// Take the screenshot:
	previewBasket->drawContents(&painter, 0, 0, previewPixmap.width(), previewPixmap.height());
	// Go back to the old look:
	previewBasket->selectSelection(selection);
	previewBasket->setFocusedNote(focusedNote);
	previewBasket->doHoverEffects();
	// End and save our splandid painting:
	painter.end();
	QImage previewImage = previewPixmap.toImage();
	const int PREVIEW_SIZE = 256;
	previewImage = previewImage.scaled(PREVIEW_SIZE, PREVIEW_SIZE, Qt::KeepAspectRatio);
	previewImage.save(tempFolder + "preview.png", "PNG");

	// Finaly Save to the Real Destination file:
	QFile file(destination);
	if (file.open(QIODevice::WriteOnly)) {
		ulong previewSize = QFile(tempFolder + "preview.png").size();
		ulong archiveSize = QFile(tempDestination).size();
		QTextStream stream(&file);
		stream.setCodec("ISO-8859-1");
		stream << "BasKetNP:archive\n"
		       << "version:0.6.1\n"
//.........这里部分代码省略.........
开发者ID:smarter,项目名称:basket,代码行数:101,代码来源:archive.cpp

示例14: main

/*!
 * \brief main
 * Ejercicio 2 Guia de Trabajos Practicos 1
 * \param argc
 * \param argv
 * \return
 */
int main(int argc, char *argv[])
{
    QApplication a( argc, argv );
    QMainWindow main;
    a.connect( &a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()) );
    main.showMaximized();
    QMdiArea *mdiArea = new QMdiArea;
    mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    main.setCentralWidget(mdiArea);

    //Inicializo con una semilla aleatoria para la generacion de Aleatorios
    qsrand( QTime::currentTime().msec() );

    // Cargo los parametros del ejercicio
    QSettings parametros( "parametros.cfg", QSettings::IniFormat );

    // Archivo de entrada
    QString archivo = QCoreApplication::applicationDirPath().append( QDir::separator() ).append( parametros.value( "archivo_entrada" ).toString() );

    // Cargo los datos de los archivos que corresponda
    matriz entradas( parametros.value( "cantidad_entradas" ).toInt() );
    QVector<int> salidas;

    qDebug() << endl << "--------------- /Datos del entrenamiento/ -----------------" << endl;
    qWarning() << "Archivo de lectura de datos originales: "<< archivo;
    if( ! leer_archivo_entrenamiento( archivo,
                                      &entradas,
                                      &salidas,
                                      parametros.value( "cantidad_entradas" ).toInt() )  ) {
        qDebug() << "No se pudo encontrar el archivo de entrenamiento! cancelando!";
        abort();
    }

    // particionamos los datos
    Particionador particiones;
    particiones.setearCantidadDatos( entradas.size() );
    particiones.setearCantidadDeParticiones( parametros.value( "cantidad_particiones" ).toInt() );
    particiones.setearPorcentajeEntrenamiento( parametros.value( "porcentaje_entrenamiento" ).toDouble() );
    particiones.setearPorcentajeValidacion( parametros.value("porcentaje_validacion").toDouble() );
    particiones.setearK(parametros.value("k").toInt());
    particiones.particionarDatos();

    // Inicializo la red neuronal
    QVector<int> neuronas_por_capas;
    // Primer parametro es la cantidad de clases
    neuronas_por_capas << parametros.value( "cant_clases" ).toInt();
    neuronas_por_capas << stringAQVector( parametros.value( "codificacion_salida" ).toString() ).size();

    // Inicilizo la red radial

    RedNeuronalRadial red( neuronas_por_capas.at(0),
                           neuronas_por_capas.at(1),
                           parametros.value("cantidad_entradas").toInt(),
                           parametros.value( "cant_clases" ).toInt()  );

    red.setearTasaAprendizaje( parametros.value( "tasa_aprendizaje" ).toDouble() );
    qDebug() << "Tasa de aprendizaje: " << parametros.value( "tasa_aprendizaje" ).toDouble();

    red.setearCodificacion( stringAQVector( parametros.value( "codificacion_salida" ).toString() ) );
    qDebug() << "Codificacion salida: " << red.mostrarCodificacionSalida();

    int max_epocas = parametros.value( "epocas_maximas", 20 ).toInt();
    qDebug() << "Epocas: " << max_epocas;

    double tolerancia_error = parametros.value( "tolerancia_error" ).toDouble();
    qDebug() << "Error de corte: " << ( tolerancia_error ) << "%";

    qDebug() << endl << "---------------- /Comienza el entrenamiento/ ----------------";

    int epoca = 0; /* Contador de epocas */
    double porcentaje_error = 100.0; /* Mucho sino sale */
    int cantidad_particiones_exitosas = 0;

    GraficadorMdi *graf1 = new GraficadorMdi( mdiArea );
    graf1->setearTitulo( QString::fromUtf8( "Porcentaje de error según particion ( entrenamiento )" ) );
    graf1->setearTituloEjeX( QString::fromUtf8( "Epoca" ) );
    graf1->setearTituloEjeY( QString::fromUtf8( "Porcentaje error" ) );
    mdiArea->addSubWindow( graf1 );
    mdiArea->tileSubWindows();

    if( stringAQVector( parametros.value( "codificacion_salida" ).toString() ).size() <= 2 ) {
        GraficadorMdi *graf2 = new GraficadorMdi( mdiArea );
        mdiArea->addSubWindow( graf2 );
        graf2->showMaximized();
        graf2->setearTitulo( "Datos originales" );
        graf2->setearEjesEnGrafico();
        graf2->setearTituloEjeX( " X " );
        graf2->setearTituloEjeY( " y " );
        graf2->agregarPuntosClasificados( entradas, salidas, 0.5 );
        mdiArea->tileSubWindows();
    } else {

//.........这里部分代码省略.........
开发者ID:tranfuga25s,项目名称:inteligencia-computacional-fich,代码行数:101,代码来源:main.cpp


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