QWindow and QMenuBar
-
-
Is there anyway to use QMenuBar with a QWindow?
I know a lot of functionality is wrapped into QMainWindow, is there a way to add this functionality to a QWindow?
Or can I create more than a single instance of QMainWindow in the same application?
-
Is there anyway to use QMenuBar with a QWindow?
I know a lot of functionality is wrapped into QMainWindow, is there a way to add this functionality to a QWindow?
Or can I create more than a single instance of QMainWindow in the same application?
@SPlatten
For the other part. There is void QLayout::setMenuBar(QWidget *widget)Tells the geometry manager to place the menu bar widget at the top of parentWidget(), outside QWidget::contentsMargins(). All child widgets are placed below the bottom edge of the menu bar.
So can't you use that to put a
QMenuBar
on anyQWidget
. But aQWindow
is a native window, not a widget, so not directly on that. Not sure you meantQWindow
? You cannot replace aQWindow
by aQMainWindow
. -
@SPlatten
For the other part. There is void QLayout::setMenuBar(QWidget *widget)Tells the geometry manager to place the menu bar widget at the top of parentWidget(), outside QWidget::contentsMargins(). All child widgets are placed below the bottom edge of the menu bar.
So can't you use that to put a
QMenuBar
on anyQWidget
. But aQWindow
is a native window, not a widget, so not directly on that. Not sure you meantQWindow
? You cannot replace aQWindow
by aQMainWindow
. -
@JonB in my application I presently have one instance of QMainWindow and several instances of QWindow, although I set-up a QMenuBar and added QMenus to it, with QActions, the menu bar is not being displayed.
-
-
@SGaist , the autocomplete suggests the function setMenuBar and the compiler doesn't complain either, yet its just a QWindow.
@SPlatten said in QWindow and QMenuBar:
and the compiler doesn't complain either, yet its just a QWindow.
Then its not a QWindow ...
-
@SGaist , the autocomplete suggests the function setMenuBar and the compiler doesn't complain either, yet its just a QWindow.
@SPlatten said in QWindow and QMenuBar:
and the compiler doesn't complain either, yet its just a QWindow.
- Show your code rather than asserting this.
- From List of All Members for QWindow where is the
setMenuBar()
method?
It's best to check your facts when (several) others say something cannot be the case. :)
-
@SPlatten said in QWindow and QMenuBar:
and the compiler doesn't complain either, yet its just a QWindow.
- Show your code rather than asserting this.
- From List of All Members for QWindow where is the
setMenuBar()
method?
It's best to check your facts when (several) others say something cannot be the case. :)
-
@JonB, @Christian-Ehrlicher , sorry, you are both correct, in trying to get something going I had messed up and the cast was to QMainWindow.
@SPlatten
:) [And I have appended a friendly smiley to my previous post.]
AQWindow
is a wrapper for a ("low-level") native window on the platform. It is not aQWidget
and cannot have something like a menubar or anything like that which a widget can have. -
@SPlatten
:) [And I have appended a friendly smiley to my previous post.]
AQWindow
is a wrapper for a ("low-level") native window on the platform. It is not aQWidget
and cannot have something like a menubar or anything like that which a widget can have. -
@JonB , is there any restriction on the number of instances of QMainWindow, can more than one instance of QMainWindow exist in the same application ?
@SPlatten
I did answer that: there is nothing special aboutQMainWindow
, it is just a widget with the style/behaviour documented at https://doc.qt.io/qt-6/qmainwindow.html#details. You can have a hundred of them if you wish. Though personally I never understand why an application would want more than one main window, but never mind. -
@SPlatten
I did answer that: there is nothing special aboutQMainWindow
, it is just a widget with the style/behaviour documented at https://doc.qt.io/qt-6/qmainwindow.html#details. You can have a hundred of them if you wish. Though personally I never understand why an application would want more than one main window, but never mind.@JonB , the application I'm working on is not a specific application to do a job at all, its an engine that when finished will allow anyone to create a Qt application in JavaScript. The engine provides the Qt functionality, JavaScript and XML are used to create the application and subscriptions.
-
@JonB , is there any restriction on the number of instances of QMainWindow, can more than one instance of QMainWindow exist in the same application ?