本文整理汇总了C++中QDialog::setAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ QDialog::setAttribute方法的具体用法?C++ QDialog::setAttribute怎么用?C++ QDialog::setAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDialog
的用法示例。
在下文中一共展示了QDialog::setAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: configureKaffeine
void MainWindow::configureKaffeine()
{
QDialog *dialog = new ConfigurationDialog(this);
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
dialog->setModal(true);
dialog->show();
}
示例2: about
void MainWindow::about()
{
QLabel *label = new QLabel;
QLabel *pix = new QLabel;
label->setText(tr("<p><b>关于</b></p> "
"<p>版本: 1.0</p>"
"<p>库: Qt 4.8.1</p>"
"<p>数据库: Sqlite</p>"
"<p>作者: 唐昊</p> "
"<p>Email:thddaniel92gmail.com</p>"));
pix->setPixmap(QPixmap("images/money.png"));
QToolButton *btn = new QToolButton;
btn->setMinimumSize(60,40);
btn->setText(tr("关闭"));
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(pix);
layout->addWidget(label);
QHBoxLayout *layout2 = new QHBoxLayout;
//layout2->addStretch(12);
layout2->addWidget(btn,Qt::AlignHCenter);
//layout2->addStretch(12);
QVBoxLayout *layout3 = new QVBoxLayout;
layout3->addLayout(layout);
layout3->addLayout(layout2);
QDialog *dlg = new QDialog;
connect(btn,SIGNAL(clicked()),dlg,SLOT(close()));
dlg->setWindowTitle(tr("关于"));
dlg->setAttribute(Qt::WA_DeleteOnClose);
dlg->setLayout(layout3);
dlg->exec();
}
示例3: handleUploadFinished
void AssetUploadDialogFactory::handleUploadFinished(AssetUpload* upload, const QString& hash) {
if (upload->getError() == AssetUpload::NoError) {
// show message box for successful upload, with copiable text for ATP hash
QDialog* hashCopyDialog = new QDialog(_dialogParent);
// delete the dialog on close
hashCopyDialog->setAttribute(Qt::WA_DeleteOnClose);
// set the window title
hashCopyDialog->setWindowTitle(tr("Successful Asset Upload"));
// setup a layout for the contents of the dialog
QVBoxLayout* boxLayout = new QVBoxLayout;
// set the label text (this shows above the text box)
QLabel* lineEditLabel = new QLabel;
lineEditLabel->setText(QString("ATP URL for %1").arg(QFileInfo(upload->getFilename()).fileName()));
// setup the line edit to hold the copiable text
QLineEdit* lineEdit = new QLineEdit;
QString atpURL = QString("%1:%2.%3").arg(URL_SCHEME_ATP).arg(hash).arg(upload->getExtension());
// set the ATP URL as the text value so it's copiable
lineEdit->insert(atpURL);
// figure out what size this line edit should be using font metrics
QFontMetrics textMetrics { lineEdit->font() };
// set the fixed width on the line edit
// pad it by 10 to cover the border and some extra space on the right side (for clicking)
static const int LINE_EDIT_RIGHT_PADDING { 10 };
lineEdit->setFixedWidth(textMetrics.width(atpURL) + LINE_EDIT_RIGHT_PADDING );
// left align the ATP URL line edit
lineEdit->home(true);
// add the label and line edit to the dialog
boxLayout->addWidget(lineEditLabel);
boxLayout->addWidget(lineEdit);
// setup an OK button to close the dialog
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);
connect(buttonBox, &QDialogButtonBox::accepted, hashCopyDialog, &QDialog::close);
boxLayout->addWidget(buttonBox);
// set the new layout on the dialog
hashCopyDialog->setLayout(boxLayout);
// show the new dialog
hashCopyDialog->show();
} else {
// display a message box with the error
showErrorDialog(upload, _dialogParent);
}
upload->deleteLater();
}
示例4: editOptions
void MainFrame::editOptions()
{
QDialog *dialog = new QDialog(this);
dialog->setAttribute(Qt::WA_DeleteOnClose);
Ui::OptionsDialog ui;
ui.setupUi(dialog);
dialog->show();
}
示例5: main
int main(int argc, char*argv[])
{
QApplication app(argc, argv);
QDialog dlg;
Ui::ByteConverterDialog ui;
ui.setupUi(&dlg);
dlg.setAttribute(Qt::WA_QuitOnClose);
dlg.show();
return app.exec();
}
示例6: largeLogo
void AboutDialog::largeLogo(){
QDialog * d = new QDialog(0);
d->setAttribute(Qt::WA_DeleteOnClose);
d->setLayout(new QHBoxLayout(d));
QLabel *l = new QLabel(d);
l->setPixmap(QPixmap(":/images/splash_large.png"));
d->layout()->addWidget(l);
d->setWindowTitle("TeXstudio");
d->exec();
}
示例7: OpenTrackerSettingsDialog
void IbisHardwareModule::OpenTrackerSettingsDialog()
{
QDialog * dialog = new QDialog();
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->setWindowTitle( "Tracker Settings" );
QVBoxLayout * layout = new QVBoxLayout( dialog );
QWidget * dlg = m_tracker->CreateSettingsDialog( dialog );
layout->addWidget( dlg );
dialog->show();
}
示例8: OnAppOptions
void WindowsApp::OnAppOptions()
{
QWinWidget *win = new QWinWidget(theApp.m_pMainWnd);
win->showCentered();
QDialog *dialog = new QDialog(win);
Ui::OptionsDialog ui;
ui.setupUi(dialog);
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->show();
}
示例9: showDialog
void NSISUpdater::showDialog(const UpdateInfo &info)
{
// if the version tag is set, there is a newer version.
QDialog *msgBox = new QDialog;
msgBox->setAttribute(Qt::WA_DeleteOnClose);
QIcon infoIcon = msgBox->style()->standardIcon(QStyle::SP_MessageBoxInformation, 0, 0);
int iconSize = msgBox->style()->pixelMetric(QStyle::PM_MessageBoxIconSize, 0, 0);
msgBox->setWindowIcon(infoIcon);
QVBoxLayout *layout = new QVBoxLayout(msgBox);
QHBoxLayout *hlayout = new QHBoxLayout;
layout->addLayout(hlayout);
msgBox->setWindowTitle(tr("New Version Available"));
QLabel *ico = new QLabel;
ico->setFixedSize(iconSize, iconSize);
ico->setPixmap(infoIcon.pixmap(iconSize));
QLabel *lbl = new QLabel;
QString txt = tr("<p>A new version of the %1 Client is available.</p>"
"<p><b>%2</b> is available for download. The installed version is %3.</p>")
.arg(Utility::escape(Theme::instance()->appNameGUI()),
Utility::escape(info.versionString()), Utility::escape(clientVersion()));
lbl->setText(txt);
lbl->setTextFormat(Qt::RichText);
lbl->setWordWrap(true);
hlayout->addWidget(ico);
hlayout->addWidget(lbl);
QDialogButtonBox *bb = new QDialogButtonBox;
bb->setWindowFlags(bb->windowFlags() & ~Qt::WindowContextHelpButtonHint);
QPushButton *skip = bb->addButton(tr("Skip this version"), QDialogButtonBox::ResetRole);
QPushButton *reject = bb->addButton(tr("Skip this time"), QDialogButtonBox::AcceptRole);
QPushButton *getupdate = bb->addButton(tr("Get update"), QDialogButtonBox::AcceptRole);
connect(skip, &QAbstractButton::clicked, msgBox, &QDialog::reject);
connect(reject, &QAbstractButton::clicked, msgBox, &QDialog::reject);
connect(getupdate, &QAbstractButton::clicked, msgBox, &QDialog::accept);
connect(skip, &QAbstractButton::clicked, this, &NSISUpdater::slotSetSeenVersion);
connect(getupdate, SIGNAL(clicked()), SLOT(slotOpenUpdateUrl()));
layout->addWidget(bb);
msgBox->open();
}
示例10: ShowCover
void AlbumCoverChoiceController::ShowCover(const Song& song) {
QDialog* dialog = new QDialog(this);
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
// Use Artist - Album as the window title
QString title_text(song.albumartist());
if (title_text.isEmpty()) title_text = song.artist();
if (!song.album().isEmpty()) title_text += " - " + song.album();
dialog->setWindowTitle(title_text);
QLabel* label = new QLabel(dialog);
label->setPixmap(AlbumCoverLoader::TryLoadPixmap(
song.art_automatic(), song.art_manual(), song.url().toLocalFile()));
dialog->resize(label->pixmap()->size());
dialog->show();
}
示例11: ShowCover
void AlbumCoverChoiceController::ShowCover(const Song& song) {
QDialog* dialog = new QDialog(this);
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
// Use (Album)Artist - Album as the window title
QString title_text(song.effective_albumartist());
if (!song.effective_album().isEmpty())
title_text += " - " + song.effective_album();
QLabel* label = new QLabel(dialog);
label->setPixmap(AlbumCoverLoader::TryLoadPixmap(
song.art_automatic(), song.art_manual(), song.url().toLocalFile()));
// add (WxHpx) to the title before possibly resizing
title_text += " (" + QString::number(label->pixmap()->width()) + "x" +
QString::number(label->pixmap()->height()) + "px)";
// if the cover is larger than the screen, resize the window
// 85% seems to be enough to account for title bar and taskbar etc.
QDesktopWidget desktop;
int current_screen = desktop.screenNumber(this);
int desktop_height = desktop.screenGeometry(current_screen).height();
int desktop_width = desktop.screenGeometry(current_screen).width();
// resize differently if monitor is in portrait mode
if (desktop_width < desktop_height) {
const int new_width = (double)desktop_width * 0.95;
if (new_width < label->pixmap()->width()) {
label->setPixmap(
label->pixmap()->scaledToWidth(new_width, Qt::SmoothTransformation));
}
} else {
const int new_height = (double)desktop_height * 0.85;
if (new_height < label->pixmap()->height()) {
label->setPixmap(label->pixmap()->scaledToHeight(
new_height, Qt::SmoothTransformation));
}
}
dialog->setWindowTitle(title_text);
dialog->setFixedSize(label->pixmap()->size());
dialog->show();
}
示例12: showPlot
void MainWindow::showPlot()
{
if(!currentImageSteps->at(currentImageSteps->size()-2))
return;
// if(!fp)
// delete fp;
QDialog* dlg = new QDialog(this);
// QHBoxLayout* mainLayout = new QHBoxLayout(dlg);
// fp = new FitnessPlot(currentImageSteps->at(currentImageSteps->size()-2));
// fp->activate(currentImageSteps->at(currentImageSteps->size()-2),ui->rBox->value());
// fp->resize(800,600);
// mainLayout->addWidget(fp);
// dlg->setLayout(mainLayout);
dlg->setAttribute(Qt::WA_DeleteOnClose);
dlg->resize(800,600);
dlg->show();
}
示例13: SetFrameWindow
void UtmpWebView::SetFrameWindow(int flag)
{
switch(flag)
{
case 0:
this->close();
break;
case 1:
this->showMinimized();
break;
case 2:
{
//全局也就只能有一个
QDialog* d = new QDialog(this,(Qt::WindowMinimizeButtonHint|Qt::WindowMaximizeButtonHint|Qt::WindowCloseButtonHint));
d->setAttribute(Qt::WA_DeleteOnClose, true);
QWebInspector* wi = new QWebInspector(d);
wi->setPage(this->page());
d->setLayout(new QVBoxLayout());
d->layout()->setMargin(0);
d->layout()->addWidget(wi);
d->show();
d->resize(600,350);
break;
}
case 3:
{
QMessageBox::StandardButton rb = QMessageBox::information(NULL, "from QT", "这是网页让QT弹出的对话框", QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if(rb == QMessageBox::Yes)
{
//这样直接调用,执行速度异常慢
//this->page()->mainFrame()->evaluateJavaScript("Ext.Msg.alert('from ext','这是QT让网页弹出的对话框');");
this->page()->mainFrame()->evaluateJavaScript("testFun();");
}
break;
}
case 4:
{
this->reload();
}
}
}
示例14: showAbout
void MainWindow::showAbout()
{
QDialog *about = new QDialog(this);
about->setAttribute(Qt::WA_DeleteOnClose);
about->setWindowTitle("About");
QVBoxLayout *aboutLayout = new QVBoxLayout;
QLabel *appName = new QLabel("BootLogo Changer 1.0", about);
QFont font = appName->font();
font.setPointSize(32);
font.setBold(true);
appName->setFont(font);
appName->setAlignment(Qt::AlignCenter);
aboutLayout->addWidget(appName);
QLabel *aboutText = new QLabel("(c) 2013 Sergey Savkin", about);
aboutLayout->addWidget(aboutText);
about->setLayout(aboutLayout);
about->show();
}
示例15: open
void MainWindow::open() {
if (QMessageBox::Yes == QMessageBox::question(this,tr("Question"),tr("Are you OK?"), \
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes)) {
QMessageBox::information(this, tr("Hmmm..."), tr("I'm glad to hear that!"));
} else {
QMessageBox::information(this, tr("Hmmm..."), tr("I'm sorry!"));
}
//dialog建立在栈上
/*//QDialog dialog(this);
//QDialog dialog;
dialog.setWindowTitle(tr("Hello, dialog!"));
dialog.exec();
//QMessageBox::information(this, tr( "Information" ), tr("Open"));
*/
//dialog建立在堆上
QDialog *dialog = new QDialog;
//dialog 使用 new 在堆上分配空间, 却一直没有 delete。可以调用可以调用 deleteLater() 函数,或者是设置 dialog 的 WindowAttribute来delete dialog。
dialog->setAttribute(Qt::WA_DeleteOnClose); // 或者 dialog->deleteLater();
dialog->setWindowTitle(tr("hello, dialog!"));
//dialog->show();
dialog->open();
}