Header: | #include <QMenuBar> |
qmake: | QT += widgets |
Inherits: | QWidget |
QMenuBar(QWidget *parent = nullptr) | |
virtual | ~QMenuBar() |
QAction * | actionAt(const QPoint &pt) const |
QRect | actionGeometry(QAction *act) const |
QAction * | activeAction() const |
QAction * | addAction(const QString &text) |
QAction * | addAction(const QString &text, const QObject *receiver, const char *member) |
QAction * | addAction(const QString &text, const Obj *receiver, PointerToMemberFunctionOrFunctor method) |
QAction * | addAction(const QString &text, Functor functor) |
QAction * | addMenu(QMenu *menu) |
QMenu * | addMenu(const QString &title) |
QMenu * | addMenu(const QIcon &icon, const QString &title) |
QAction * | addSeparator() |
void | clear() |
QWidget * | cornerWidget(Qt::Corner corner = Qt::TopRightCorner) const |
QAction * | insertMenu(QAction *before, QMenu *menu) |
QAction * | insertSeparator(QAction *before) |
bool | isDefaultUp() const |
bool | isNativeMenuBar() const |
void | setActiveAction(QAction *act) |
void | setCornerWidget(QWidget *widget, Qt::Corner corner = Qt::TopRightCorner) |
void | setDefaultUp(bool) |
void | setNativeMenuBar(bool nativeMenuBar) |
NSMenu * | toNSMenu() |
virtual int | heightForWidth(int) const override |
virtual QSize | minimumSizeHint() const override |
virtual QSize | sizeHint() const override |
void | hovered(QAction *action) |
void | triggered(QAction *action) |
void | initStyleOption(QStyleOptionMenuItem *option, const QAction *action) const |
virtual void | actionEvent(QActionEvent *e) override |
virtual void | changeEvent(QEvent *e) override |
virtual bool | event(QEvent *e) override |
virtual bool | eventFilter(QObject *object, QEvent *event) override |
virtual void | focusInEvent(QFocusEvent *) override |
virtual void | focusOutEvent(QFocusEvent *) override |
virtual void | keyPressEvent(QKeyEvent *e) override |
virtual void | leaveEvent(QEvent *) override |
virtual void | mouseMoveEvent(QMouseEvent *e) override |
virtual void | mousePressEvent(QMouseEvent *e) override |
virtual void | mouseReleaseEvent(QMouseEvent *e) override |
virtual void | paintEvent(QPaintEvent *e) override |
virtual void | resizeEvent(QResizeEvent *) override |
virtual void | timerEvent(QTimerEvent *e) override |
menubar
is a pointer to a QMenuBar and fileMenu
is a pointer to a QMenu, the following statement inserts the menu into the menu bar:String matches | Placement | Notes |
---|---|---|
about.* | Application Menu | About <application name> | The application name is fetched from the Info.plist file (see note below). If this entry is not found no About item will appear in the Application Menu. |
config, options, setup, settings or preferences | Application Menu | Preferences | If this entry is not found the Settings item will be disabled |
quit or exit | Application Menu | Quit <application name> | If this entry is not found a default Quit item will be created to call QCoreApplication::quit() |
Info.plist
file in the application's bundle. See Qt for macOS - Deployment for more information.true
, the menubar is used in the native menubar and is not in the window of its parent; if false
the menubar remains in the window. On other platforms, setting this attribute has no effect, and reading this attribute will always return false
.bool | isNativeMenuBar() const |
void | setNativeMenuBar(bool nativeMenuBar) |
[signal]
void QMenuBar::hovered(QAction *action)[override virtual slot]
void QMenuBar::setVisible(boolvisible)[signal]
void QMenuBar::triggered(QAction *action)[virtual]
QMenuBar::~QMenuBar()nullptr
if there is no action at pt or if the location has a separator.[override virtual protected]
void QMenuBar::actionEvent(QActionEvent *e)nullptr
.[override virtual protected]
void QMenuBar::changeEvent(QEvent *e)[override virtual protected]
bool QMenuBar::event(QEvent *e)[override virtual protected]
bool QMenuBar::eventFilter(QObject *object, QEvent *event)[override virtual protected]
void QMenuBar::focusInEvent(QFocusEvent *)[override virtual protected]
void QMenuBar::focusOutEvent(QFocusEvent *)[override virtual]
int QMenuBar::heightForWidth(int) const[protected]
void QMenuBar::initStyleOption(QStyleOptionMenuItem *option, const QAction *action) const[override virtual protected]
void QMenuBar::keyPressEvent(QKeyEvent *e)[override virtual protected]
void QMenuBar::leaveEvent(QEvent *)[override virtual]
QSize QMenuBar::minimumSizeHint() const[override virtual protected]
void QMenuBar::mouseMoveEvent(QMouseEvent *e)[override virtual protected]
void QMenuBar::mousePressEvent(QMouseEvent *e)[override virtual protected]
void QMenuBar::mouseReleaseEvent(QMouseEvent *e)[override virtual protected]
void QMenuBar::paintEvent(QPaintEvent *e)[override virtual protected]
void QMenuBar::resizeEvent(QResizeEvent *)[override virtual]
QSize QMenuBar::sizeHint() const[override virtual protected]
void QMenuBar::timerEvent(QTimerEvent *e)django.contrib.staticfiles
to help you manage them.django.contrib.staticfiles
is included in yourINSTALLED_APPS
.STATIC_URL
, for example:static
template tag to build the URL forthe given relative path using the configured STATICFILES_STORAGE
.static
in your app. Forexample my_app/static/my_app/example.jpg
.django.contrib.staticfiles
, this willbe done automatically by runserver
when DEBUG
is setto True
(see django.contrib.staticfiles.views.serve()
).static/
directory inside your apps,you can define a list of directories (STATICFILES_DIRS
) in yoursettings file where Django will also look for static files. For example:STATICFILES_FINDERS
setting fordetails on how staticfiles
finds your files.my_app/static/
(rather than creating another my_app
subdirectory), but it would actually be a bad idea. Django will use thefirst static file it finds whose name matches, and if you had a static filewith the same name in a different application, Django would be unable todistinguish between them. We need to be able to point Django at the rightone, and the best way to ensure this is by namespacing them. That is,by putting those static files inside another directory named for theapplication itself.STATICFILES_DIRS
byspecifying prefixes.django.contrib.staticfiles
as explained above,runserver
will do this automatically when DEBUG
is setto True
. If you don’t have django.contrib.staticfiles
inINSTALLED_APPS
, you can still manually serve static files using thedjango.views.static.serve()
view.STATIC_URL
is defined as /static/
, you can dothis by adding the following snippet to your urls.py:/static/
) and not a URL (e.g.http://static.example.com/
).STATIC_ROOT
folder; it doesn’t perform static files discovery likedjango.contrib.staticfiles
.MEDIA_ROOT
using the django.views.static.serve()
view.MEDIA_URL
is defined as /media/
, you can dothis by adding the following snippet to your urls.py:/media/
) and not a URL (e.g.http://media.example.com/
).LiveServerTestCase
) the static assets need to be served alongthe rest of the content so the test environment reproduces the real one asfaithfully as possible, but LiveServerTestCase
has only very basic staticfile-serving functionality: It doesn’t know about the finders feature of thestaticfiles
application and assumes the static content has already beencollected under STATIC_ROOT
.staticfiles
ships its owndjango.contrib.staticfiles.testing.StaticLiveServerTestCase
, a subclassof the built-in one that has the ability to transparently serve all the assetsduring execution of these tests in a way very similar to what we get atdevelopment time with DEBUG=True
, i.e. without having to collect themusing collectstatic
first.django.contrib.staticfiles
provides a convenience management commandfor gathering static files in a single directory so you can serve them easily.STATIC_ROOT
setting to the directory from which you’dlike to serve these files, for example:collectstatic
management command:STATIC_ROOT
directory.django.contrib.staticfiles
, see the staticfilesreference.