Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
main.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
4
#
include
<
QtWidgets
>
5
6
class
Widget
:
public
QWidget
7
{
8
public
:
9
Widget
(QWidget *parent =
nullptr
);
10
};
11
12
Widget
::
Widget
(QWidget *parent)
13
:
QWidget
(
parent
)
14
{
15
//! [0]
16
QWidget *firstPageWidget =
new
QWidget;
17
QWidget *secondPageWidget =
new
QWidget;
18
QWidget *thirdPageWidget =
new
QWidget;
19
20
QStackedLayout *stackedLayout =
new
QStackedLayout;
21
stackedLayout->addWidget(firstPageWidget);
22
stackedLayout->addWidget(secondPageWidget);
23
stackedLayout->addWidget(thirdPageWidget);
24
25
//! [0]
26
27
//! [1]
28
QComboBox *pageComboBox =
new
QComboBox;
29
pageComboBox->addItem(tr(
"Page 1"
));
30
pageComboBox->addItem(tr(
"Page 2"
));
31
pageComboBox->addItem(tr(
"Page 3"
));
32
connect(pageComboBox, &QComboBox::activated,
33
stackedLayout, &QStackedLayout::setCurrentIndex);
34
//! [1]
35
36
//! [2]
37
QVBoxLayout *mainLayout =
new
QVBoxLayout;
38
//! [2]
39
40
mainLayout->addWidget(pageComboBox);
41
42
//! [3]
43
mainLayout->addLayout(stackedLayout);
44
setLayout(mainLayout);
45
//! [3]
46
}
47
48
int
main
(
int
argc,
char
*argv[])
49
{
50
QApplication app(argc, argv);
51
Widget
widget;
52
widget.show();
53
return
app.exec();
54
}
Widget
Definition
main.cpp:21
Widget::Widget
Widget(QWidget *parent=nullptr)
Definition
main.cpp:26
main
int main(int argc, char *argv[])
[ctor_close]
Definition
src_corelib_animation_qpropertyanimation.cpp:100
qtbase
src
widgets
doc
snippets
qstackedlayout
main.cpp
Generated on
for Qt by
1.18.0