本文整理汇总了C++中QDialog::close方法的典型用法代码示例。如果您正苦于以下问题:C++ QDialog::close方法的具体用法?C++ QDialog::close怎么用?C++ QDialog::close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDialog
的用法示例。
在下文中一共展示了QDialog::close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: duplicate_clicked
void QgsComposerManager::duplicate_clicked()
{
QListWidgetItem* item = mComposerListWidget->currentItem();
if ( !item )
{
return;
}
QgsComposer* currentComposer = 0;
QString currentTitle;
QMap<QListWidgetItem*, QgsComposer*>::iterator it = mItemComposerMap.find( item );
if ( it != mItemComposerMap.end() )
{
currentComposer = it.value();
currentTitle = it.value()->title();
}
else
{
return;
}
QString newTitle = QgisApp::instance()->uniqueComposerTitle( this, false, currentTitle + tr( " copy" ) );
if ( newTitle.isNull() )
{
return;
}
// provide feedback, since loading of template into duplicate composer will be hidden
QDialog* dlg = currentComposer->busyIndicatorDialog( tr( "Duplicating composer..." ), this );
dlg->show();
QgsComposer* newComposer = QgisApp::instance()->duplicateComposer( currentComposer, newTitle );
dlg->close();
if ( newComposer )
{
// extra activation steps for Windows
hide();
newComposer->activate();
// no need to add new composer to list widget, if just closing this->exec();
close();
}
else
{
QMessageBox::warning( this, tr( "Duplicate Composer" ),
tr( "Composer duplication failed." ) );
}
}
示例2: on_mAddButton_clicked
void QgsComposerManager::on_mAddButton_clicked()
{
QFile templateFile;
bool loadingTemplate = ( mTemplate->currentIndex() > 0 );
if ( loadingTemplate )
{
if ( mTemplate->currentIndex() == 1 )
{
templateFile.setFileName( mTemplatePathLineEdit->text() );
}
else
{
templateFile.setFileName( mTemplate->itemData( mTemplate->currentIndex() ).toString() );
}
if ( !templateFile.exists() )
{
QMessageBox::warning( this, tr( "Template error" ), tr( "Error, template file not found" ) );
return;
}
if ( !templateFile.open( QIODevice::ReadOnly ) )
{
QMessageBox::warning( this, tr( "Template error" ), tr( "Error, could not read file" ) );
return;
}
}
QgsComposer* newComposer = 0;
bool loadedOK = false;
QString title = QgisApp::instance()->uniqueComposerTitle( this, true );
if ( title.isNull() )
{
return;
}
newComposer = QgisApp::instance()->createNewComposer( title );
if ( !newComposer )
{
QMessageBox::warning( this, tr( "Composer error" ), tr( "Error, could not create composer" ) );
return;
}
else
{
loadedOK = true;
}
if ( loadingTemplate )
{
QDomDocument templateDoc;
if ( templateDoc.setContent( &templateFile, false ) )
{
// provide feedback, since composer will be hidden when loading template (much faster)
// (not needed for empty composer)
QDialog* dlg = newComposer->busyIndicatorDialog( tr( "Loading template into composer..." ), this );
dlg->show();
newComposer->hide();
loadedOK = newComposer->composition()->loadFromTemplate( templateDoc, 0, false );
newComposer->activate();
dlg->close();
}
}
if ( loadedOK )
{
// do not close on Add, since user may want to add multiple composers from templates
QListWidgetItem* item = new QListWidgetItem( newComposer->title(), mComposerListWidget );
item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable );
mItemComposerMap.insert( item, newComposer );
mComposerListWidget->sortItems();
mComposerListWidget->setCurrentItem( item );
mComposerListWidget->setFocus();
}
else
{
if ( newComposer )
{
newComposer->close();
QgisApp::instance()->deleteComposer( newComposer );
newComposer = 0;
}
QMessageBox::warning( this, tr( "Template error" ), tr( "Error, could not load template file" ) );
}
}
示例3: on_mAddButton_clicked
void QgsComposerManager::on_mAddButton_clicked()
{
QFile templateFile;
bool loadingTemplate = ( mTemplate->currentIndex() > 0 );
if ( loadingTemplate )
{
if ( mTemplate->currentIndex() == 1 )
{
templateFile.setFileName( mTemplatePathLineEdit->text() );
}
else
{
templateFile.setFileName( mTemplate->itemData( mTemplate->currentIndex() ).toString() );
}
if ( !templateFile.exists() )
{
QMessageBox::warning( this, tr( "Template error" ), tr( "Error, template file not found" ) );
return;
}
if ( !templateFile.open( QIODevice::ReadOnly ) )
{
QMessageBox::warning( this, tr( "Template error" ), tr( "Error, could not read file" ) );
return;
}
}
QgsComposer* newComposer = 0;
bool loadedOK = false;
QString title = QgisApp::instance()->uniqueComposerTitle( this, true );
if ( title.isNull() )
{
return;
}
newComposer = QgisApp::instance()->createNewComposer( title );
if ( !newComposer )
{
QMessageBox::warning( this, tr( "Composer error" ), tr( "Error, could not create composer" ) );
return;
}
else
{
loadedOK = true;
}
if ( loadingTemplate )
{
QDomDocument templateDoc;
if ( templateDoc.setContent( &templateFile, false ) )
{
// provide feedback, since composer will be hidden when loading template (much faster)
// (not needed for empty composer)
QDialog* dlg = new QgsBusyIndicatorDialog( tr( "Loading template into composer..." ) );
dlg->setStyleSheet( QgisApp::instance()->styleSheet() );
dlg->show();
newComposer->hide();
loadedOK = newComposer->composition()->loadFromTemplate( templateDoc, 0, false );
newComposer->activate();
dlg->close();
delete dlg;
dlg = 0;
}
}
if ( !loadedOK )
{
newComposer->close();
QgisApp::instance()->deleteComposer( newComposer );
newComposer = 0;
QMessageBox::warning( this, tr( "Template error" ), tr( "Error, could not load template file" ) );
}
}