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
8class MainWindow : public QMainWindow
9{
10public:
11 explicit MainWindow(QWidget *parent = nullptr);
12};
13
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
39int main(int argc, char *argv[])
40{
41 QApplication app(argc, argv);
43 window.show();
44 return app.exec();
45}
46
MainWindow(QWidget *parent=nullptr)
QAction * newAct
Definition whatsthis.cpp:11
The QAction class provides an abstraction for user commands that can be added to different user inter...
Definition qaction.h:30
void setStatusTip(const QString &statusTip)
Definition qaction.cpp:712
The QApplication class manages the GUI application's control flow and main settings.
static int exec()
Enters the main event loop and waits until exit() is called, then returns the value that was set to e...
The QMainWindow class provides a main application window.
Definition qmainwindow.h:25
void setCentralWidget(QWidget *widget)
Sets the given widget to be the main window's central widget.
QAction * addMenu(QMenu *menu)
Appends menu to the menu bar.
Definition qmenubar.cpp:768
The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus.
Definition qmenu.h:26
void addAction(QAction *action)
Appends the action action to this widget's list of actions.
Definition qwidget.cpp:3117
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
friend class QWidget
Definition qobject.h:382
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
void setWindowTitle(const QString &)
Definition qwidget.cpp:6105
int main()
[0]
#define tr(X)
QApplication app(argc, argv)
[0]
aWidget window() -> setWindowTitle("New Window Title")
[2]
QMenuBar * menuBar
[0]
statusBar() -> addWidget(new MyReadWriteIndication)
[0]