Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
#include <QApplication>
4
#include <QMainWindow>
5
#include <QMenuBar>
6
#include <QStatusBar>
7
8
class
MainWindow
:
public
QMainWindow
9
{
10
public
:
11
explicit
MainWindow
(
QWidget
*
parent
=
nullptr
);
12
};
13
15
MainWindow::MainWindow
(
QWidget
*parent)
16
:
QMainWindow
(parent)
17
{
19
QWidget
*myWidget =
new
QWidget
;
20
myWidget->setStatusTip(
tr
(
"This is my widget."
));
21
22
setCentralWidget
(myWidget);
24
26
QMenu
*fileMenu =
menuBar
()->
addMenu
(
tr
(
"File"
));
27
28
QAction
*
newAct
=
new
QAction
(
tr
(
"&New"
),
this
);
29
newAct
->
setStatusTip
(
tr
(
"Create a new file."
));
30
fileMenu->
addAction
(
newAct
);
32
33
statusBar
()->showMessage(
tr
(
"Ready"
));
34
setWindowTitle
(
tr
(
"QStatusTipEvent"
));
36
}
38
39
int
main
(
int
argc,
char
*argv[])
40
{
41
QApplication
app
(argc, argv);
42
MainWindow
window
;
43
window
.show();
44
return
app
.
exec
();
45
}
46
MainWindow
[5]
Definition
src_corelib_kernel_qobject.cpp:52
MainWindow::MainWindow
MainWindow()
[17]
Definition
src_corelib_kernel_qobject.cpp:63
MainWindow::MainWindow
MainWindow(QWidget *parent=nullptr)
MainWindow::newAct
QAction * newAct
Definition
whatsthis.cpp:11
QAction
The QAction class provides an abstraction for user commands that can be added to different user inter...
Definition
qaction.h:30
QAction::setStatusTip
void setStatusTip(const QString &statusTip)
Definition
qaction.cpp:712
QApplication
The QApplication class manages the GUI application's control flow and main settings.
Definition
qapplication.h:32
QApplication::exec
static int exec()
Enters the main event loop and waits until exit() is called, then returns the value that was set to e...
Definition
qapplication.cpp:2560
QMainWindow
The QMainWindow class provides a main application window.
Definition
qmainwindow.h:25
QMainWindow::setCentralWidget
void setCentralWidget(QWidget *widget)
Sets the given widget to be the main window's central widget.
Definition
qmainwindow.cpp:596
QMenuBar::addMenu
QAction * addMenu(QMenu *menu)
Appends menu to the menu bar.
Definition
qmenubar.cpp:768
QMenu
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus.
Definition
qmenu.h:26
QMenu::addAction
void addAction(QAction *action)
Appends the action action to this widget's list of actions.
Definition
qwidget.cpp:3117
QObject::parent
QObject * parent() const
Returns a pointer to the parent object.
Definition
qobject.h:346
QObject::QWidget
friend class QWidget
Definition
qobject.h:382
QWidget
The QWidget class is the base class of all user interface objects.
Definition
qwidget.h:99
QWidget::setWindowTitle
void setWindowTitle(const QString &)
Definition
qwidget.cpp:6105
main
int main()
[0]
Definition
doc_src_objecttrees.cpp:5
tr
#define tr(X)
Definition
qtemporaryfile.cpp:21
app
QApplication app(argc, argv)
[0]
window
aWidget window() -> setWindowTitle("New Window Title")
[2]
menuBar
QMenuBar * menuBar
[0]
Definition
src_gui_widgets_qmenubar.cpp:10
statusBar
statusBar() -> addWidget(new MyReadWriteIndication)
[0]
qtbase
src
gui
doc
snippets
qstatustipevent
main.cpp
Generated by
1.10.0