Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
imagedialog.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3// Qt-Security score:significant reason:default
4
5#include <QMessageBox>
6
7#include "imagedialog.h"
8
9//! [0]
10ImageDialog::ImageDialog(QWidget *parent)
11 : QDialog(parent)
12{
13 setupUi(this);
14 okButton->setAutoDefault(false);
15 cancelButton->setAutoDefault(false);
16//! [0]
17
18 colorDepthCombo->addItem(tr("2 colors (1 bit per pixel)"));
19 colorDepthCombo->addItem(tr("4 colors (2 bits per pixel)"));
20 colorDepthCombo->addItem(tr("16 colors (4 bits per pixel)"));
21 colorDepthCombo->addItem(tr("256 colors (8 bits per pixel)"));
22 colorDepthCombo->addItem(tr("65536 colors (16 bits per pixel)"));
23 colorDepthCombo->addItem(tr("16 million colors (24 bits per pixel)"));
24
25 connect(cancelButton, &QAbstractButton::clicked, this, &QDialog::reject);
26//! [1]
27 connect(okButton, &QAbstractButton::clicked, this, &ImageDialog::checkValues);
28}
29//! [1]
30
31//! [2]
32void ImageDialog::checkValues()
33{
34 if (nameLineEdit->text().isEmpty()) {
35 QMessageBox::information(this, tr("No Image Name"),
36 tr("Please supply a name for the image."), QMessageBox::Cancel);
37 } else {
38 accept();
39 }
40}
41//! [2]