QMenuBar, QMenu and QAction
-
I am trying to programmatically add QMenuBar, QMenu and QAction to a dynamically created instance of QMainWindow.
The configuration is read from an XML file:
<menubar id="mnuBar"> <menu id="mnuFile" text="File" tooltip="File tooltip!" shortcut="Ctrl+F"> <action text="New" tooltip="New tooltip!" shortcut="Ctrl+N"/> <action text="Open" tooltip="Open tooltip!" shortcut="Ctrl+O"/> <action text="Save" tooltip="Save tooltip!" shortcut="Ctrl+S"/> </menu> </menubar>
The code that processes the XML:
} else if ( mstrName.compare(clsXMLnode::mscszNodeMenu) == 0 ) { Q_ASSERT_X( blnIsParentAMenuBar()==true, cpszClassConstr , "Menu's can only be added to a menu bar!"); const QString cstrShortcut(strGetAttribute(clsXMLnode::mscszAttrShortcut)) ,cstrText(strGetAttribute(clsXMLnode::mscszAttrText)) ,cstrTooltip(strGetAttribute(clsXMLnode::mscszAttrTooltip)); QMenuBar* pobjMenuBar(qobject_cast<QMenuBar*>(pobjParWidget)); Q_ASSERT_X(pobjMenuBar!=nullptr, cpszClassConstr, "Menu bar isn't present"); QMenu* pobjMenu(new QMenu(pobjMenuBar)); Q_ASSERT_X(pobjMenu!=nullptr, cpszClassConstr, "Menu cannot be created!"); QAction* pobjAction(pobjMenu->menuAction()); if ( pobjAction != nullptr ) { pobjAction->setShortcut(cstrShortcut); pobjAction->setText(cstrText); pobjAction->setToolTip(cstrTooltip); pobjMenuBar->addAction(pobjAction); pobjWidget = pobjMenu; } } else if ( mstrName.compare(clsXMLnode::mscszNodeMenuBar) == 0 ) { //The parent node must be a window if ( pobjParent != nullptr ) { QMainWindow* pobjWindow(pobjParent->pobjGetMainWindow()); if ( pobjWindow != nullptr ) { QMenuBar* pobjMenuBar(new QMenuBar(pobjWindow)); if ( pobjMenuBar != nullptr ) { int intHeight(pobjMenuBar->fontMetrics().height()); QRect rctWindow(pobjWindow->geometry()) ,rctMenuBar(0, 0, rctWindow.width(), intHeight); pobjMenuBar->setGeometry(rctMenuBar); pobjWindow->setMenuBar(pobjMenuBar); pobjWidget = pobjMenuBar; } } } }
I've been through this quite a few times and everything in the debugger looks ok, but I'm not seeing the menu bar or the menu in the window. Everything else looks ok, I've compared the logic with a UI I've created in Qt Creator and cannot see what I've missed.
-
@SGaist , I just used Qt Creator to add a menu to the splash window I've created and when the splash window gets the focus, the menu does appear in the top left of the desktop, but this isn't true of my programmatically created window when it gets the focus.
-
I've been looking at a UI which I modified in Qt Creator to add a menu, this works:
/******************************************************************************** ** Form generated from reading UI file 'splash.ui' ** ** Created by: Qt User Interface Compiler version 5.15.2 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ #ifndef UI_SPLASH_H #define UI_SPLASH_H #include <QtCore/QVariant> #include <QtWidgets/QAction> #include <QtWidgets/QApplication> #include <QtWidgets/QLabel> #include <QtWidgets/QMainWindow> #include <QtWidgets/QMenu> #include <QtWidgets/QMenuBar> #include <QtWidgets/QWidget> QT_BEGIN_NAMESPACE class Ui_splash { public: QAction *actionAnother_Menu; QWidget *centralwidget; QLabel *lblHdr; QLabel *lblAppTitle; QLabel *lblWidth; QLabel *lblHeight; QLabel *lblWidthVal; QLabel *lblHeightVal; QMenuBar *menuBar; QMenu *menuTest; void setupUi(QMainWindow *splash) { if (splash->objectName().isEmpty()) splash->setObjectName(QString::fromUtf8("splash")); splash->setWindowModality(Qt::NonModal); splash->resize(172, 102); splash->setFocusPolicy(Qt::NoFocus); splash->setWindowTitle(QString::fromUtf8("")); #if QT_CONFIG(tooltip) splash->setToolTip(QString::fromUtf8("")); #endif // QT_CONFIG(tooltip) #if QT_CONFIG(statustip) splash->setStatusTip(QString::fromUtf8("")); #endif // QT_CONFIG(statustip) actionAnother_Menu = new QAction(splash); actionAnother_Menu->setObjectName(QString::fromUtf8("actionAnother_Menu")); centralwidget = new QWidget(splash); centralwidget->setObjectName(QString::fromUtf8("centralwidget")); centralwidget->setStyleSheet(QString::fromUtf8("background-color:#ff333333")); lblHdr = new QLabel(centralwidget); lblHdr->setObjectName(QString::fromUtf8("lblHdr")); lblHdr->setGeometry(QRect(7, 0, 161, 38)); lblHdr->setText(QString::fromUtf8("")); lblHdr->setPixmap(QPixmap(QString::fromUtf8(":/CMPY_LOGO"))); lblHdr->setScaledContents(false); lblHdr->setAlignment(Qt::AlignCenter); lblAppTitle = new QLabel(centralwidget); lblAppTitle->setObjectName(QString::fromUtf8("lblAppTitle")); lblAppTitle->setGeometry(QRect(8, 40, 161, 20)); lblAppTitle->setStyleSheet(QString::fromUtf8("color:#ffffffff;")); lblAppTitle->setAlignment(Qt::AlignCenter); lblAppTitle->setOpenExternalLinks(true); lblWidth = new QLabel(centralwidget); lblWidth->setObjectName(QString::fromUtf8("lblWidth")); lblWidth->setGeometry(QRect(8, 80, 91, 20)); lblWidth->setStyleSheet(QString::fromUtf8("color:#ffffffff;")); lblWidth->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter); lblHeight = new QLabel(centralwidget); lblHeight->setObjectName(QString::fromUtf8("lblHeight")); lblHeight->setGeometry(QRect(8, 60, 91, 20)); lblHeight->setStyleSheet(QString::fromUtf8("color:#ffffffff;")); lblHeight->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter); lblWidthVal = new QLabel(centralwidget); lblWidthVal->setObjectName(QString::fromUtf8("lblWidthVal")); lblWidthVal->setGeometry(QRect(110, 80, 60, 20)); lblWidthVal->setStyleSheet(QString::fromUtf8("color:#ffffffff;")); lblWidthVal->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); lblHeightVal = new QLabel(centralwidget); lblHeightVal->setObjectName(QString::fromUtf8("lblHeightVal")); lblHeightVal->setGeometry(QRect(110, 60, 60, 20)); lblHeightVal->setStyleSheet(QString::fromUtf8("color:#ffffffff;")); lblHeightVal->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); splash->setCentralWidget(centralwidget); menuBar = new QMenuBar(splash); menuBar->setObjectName(QString::fromUtf8("menuBar")); menuBar->setGeometry(QRect(0, 0, 172, 24)); menuTest = new QMenu(menuBar); menuTest->setObjectName(QString::fromUtf8("menuTest")); splash->setMenuBar(menuBar); menuBar->addAction(menuTest->menuAction()); menuTest->addAction(actionAnother_Menu); retranslateUi(splash); QMetaObject::connectSlotsByName(splash); } // setupUi void retranslateUi(QMainWindow *splash) { actionAnother_Menu->setText(QCoreApplication::translate("splash", "Another Menu", nullptr)); #if QT_CONFIG(tooltip) lblAppTitle->setToolTip(QCoreApplication::translate("splash", "XML Multi-Platform Application Manager", nullptr)); #endif // QT_CONFIG(tooltip) lblAppTitle->setText(QCoreApplication::translate("splash", "XMLMPAM", nullptr)); lblWidth->setText(QCoreApplication::translate("splash", "Display width: ", nullptr)); lblHeight->setText(QCoreApplication::translate("splash", "Display height:", nullptr)); lblWidthVal->setText(QCoreApplication::translate("splash", "0", nullptr)); lblHeightVal->setText(QCoreApplication::translate("splash", "0", nullptr)); menuTest->setTitle(QCoreApplication::translate("splash", "Test", nullptr)); (void)splash; } // retranslateUi }; namespace Ui { class splash: public Ui_splash {}; } // namespace Ui QT_END_NAMESPACE #endif // UI_SPLASH_H
I then tried to replicate this in my own, the code is now:
} else if ( mstrName.compare(clsXMLnode::mscszNodeMenu) == 0 ) { Q_ASSERT_X(blnIsParentAMenuBar()==true, cpszClassConstr , "Menu's can only be added to a menu bar!"); const QString cstrShortcut(strGetAttribute(clsXMLnode::mscszAttrShortcut)) ,cstrText(strGetAttribute(clsXMLnode::mscszAttrText)) ,cstrTooltip(strGetAttribute(clsXMLnode::mscszAttrTooltip)); clsXMLnode* pobjMainWindowNode(nullptr); if ( pobjParent != nullptr && pobjParent->mpobjParent != nullptr ) { pobjMainWindowNode = pobjParent->mpobjParent; } Q_ASSERT_X(pobjMainWindowNode!=nullptr && pobjMainWindowNode->mpobjMainWindow!=nullptr, cpszClassConstr ,"Cannot get parent window!"); QMainWindow* pobjMainWindow(pobjMainWindowNode->mpobjMainWindow); QMenuBar* pobjMenuBar(pobjMainWindow->menuBar()); Q_ASSERT_X(pobjMenuBar!=nullptr, cpszClassConstr, "Menu bar isn't present!"); QMenu* pobjMenu(new QMenu(pobjMenuBar)); Q_ASSERT_X(pobjMenu!=nullptr, cpszClassConstr, "Menu cannot be created!"); QAction* pobjAction(pobjMenu->menuAction()); if ( pobjAction != nullptr ) { pobjAction->setShortcut(cstrShortcut); pobjAction->setText(cstrText); pobjAction->setToolTip(cstrTooltip); pobjMenuBar->addAction(pobjAction); pobjMainWindow->setMenuBar(pobjMenuBar); pobjWidget = pobjMenu; } } else if ( mstrName.compare(clsXMLnode::mscszNodeMenuBar) == 0 ) { //The parent node must be a window if ( pobjParent != nullptr && pobjParent->blnIsMainWindow() == true ) { QMainWindow* pobjMainWindow(pobjParent->pobjGetMainWindow()); if ( pobjMainWindow != nullptr ) { QMenuBar* pobjMenuBar(new QMenuBar(pobjMainWindow)); if ( pobjMenuBar != nullptr ) { int intHeight(pobjMenuBar->fontMetrics().height()); QRect rctWindow(pobjParent->rctGetGeometry()) ,rctMenuBar(0, 0, 172,24); //rctWindow.width(), intHeight); pobjMenuBar->setGeometry(rctMenuBar); pobjWidget = pobjMenuBar; } } } }
I've singled stepped in the debugger and all the pointers are correct and valid, but I do not see the menus at the top of the desktop when the window has the focus. Can anyone help or suggest how it could be different and what could be wrong?
-
I used
MainWindow w; // standard mainwindow defined using UI QMainWindow* myMW(&w); // myMW points to w QMenuBar* myMenuBar(myMW->menuBar()); QMenu* myMenu(new QMenu(myMenuBar)); QAction* myAction(myMenu->menuAction()); myMenuBar->addAction(myAction); myAction->setText("myAction"); myMW->setMenuBar(myMenuBar); myMW->show(); // basically showing w
to reproduce your code.
And it works. I see myMainWindow
while the newQMenu
and the corresponding action were added to the existingQMenuBar
.I feel a bit silly to ask this, but are you aware that you are working on the "toplevel"
QMainWindow
the whole time?! Or is it just the "splash"QMainWindow
here? Somewhere (maybe even in a separate post) you've mentioned twoQMainWindow
(are you looking at the right one?!)As @SGaist mentioned, check your
QMainWindow
object tree, esp. what widget is parent of what subwidgets, menu, etc. -
@SPlatten said in QMenuBar, QMenu and QAction:
@SGaist , how do I do that?
Do what? "dump the object tree to see how is your QMainWindow structured"?
Every
QObject
(including widgets) has const QObjectList &QObject::children() const. @SGaist suggests you write a debugging routine which calls that recursively starting from yourQMainWindow
so as to examine the actual object tree (widgets) hierarchy. -
@JonB said in QMenuBar, QMenu and QAction:
@SPlatten said in QMenuBar, QMenu and QAction:
@SGaist , how do I do that?
Do what? "dump the object tree to see how is your QMainWindow structured"?
Every
QObject
(including widgets) has const QObjectList &QObject::children() const. @SGaist suggests you write a debugging routine which calls that recursively starting from yourQMainWindow
so as to examine the actual object tree (widgets) hierarchy.I was rather thinking of dumpObjectTree but that's the idea.
-
@SPlatten
I haven't followed your code, but if you mean that it is taking the menubar which has been set on aQMainWindow
and callingsetMenuBar()
on it to set it elsewhere I don't think you can do that. But maybe that's not what your code is trying to do, I don't know. -
@SGaist , I added:
qdbg() << "dumpObectTree"; pobjMainWindow->dumpObjectTree();
The result in my log:
dumpObectTree S000000000004E000000000214T09:04:55.954D:QMainWindow:: S000000000005E000000000214T09:04:55.954D: QMainWindowLayout::_layout S000000000006E000000000214T09:04:55.954D: QWidget:: S000000000007E000000000214T09:04:55.954D: QPropertyAnimation:: S000000000008E000000000214T09:04:55.954D: QPropertyAnimation:: S000000000009E000000000214T09:04:55.954D: QMenuBar:: S000000000010E000000000214T09:04:55.954D: QToolButton::qt_menubar_ext_button S000000000011E000000000214T09:04:55.954D: QMenu:: S000000000012E000000000214T09:04:55.954D: QAction::
-
@SGaist, @JonB, @Pl45m4 , found something...
In Qt Creator I edited the splash window and added a menubar to it, I then added a single menu to that, compiled, nothing was displayed, then I added a submenu and compiled again, this time the menu was displayed. I have experimented removing the submenu, compiled and run and each time there is no submenu then the top line menu is not shown either.
-
@SPlatten
Let's get Creator out of this. You can see the code it generates in theui_....h
file. Using that you can produce a minimal example showing the behaviour you state, for good and for bad.Depending on what that is, I have no knowledge whether MacOS is relevant, I know that does something about top-level menus. Nor do I know whether "splash screen" is relevant. I know no more than this.
-
@JonB , this is the splash ui_splash.h that works, however only when it has a submenu with actions.
/******************************************************************************** ** Form generated from reading UI file 'splash.ui' ** ** Created by: Qt User Interface Compiler version 5.15.2 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ #ifndef UI_SPLASH_H #define UI_SPLASH_H #include <QtCore/QVariant> #include <QtWidgets/QAction> #include <QtWidgets/QApplication> #include <QtWidgets/QLabel> #include <QtWidgets/QMainWindow> #include <QtWidgets/QMenu> #include <QtWidgets/QMenuBar> #include <QtWidgets/QWidget> QT_BEGIN_NAMESPACE class Ui_splash { public: QAction *action_New; QAction *action_Open; QAction *action_Save; QWidget *centralwidget; QLabel *lblHdr; QLabel *lblAppTitle; QLabel *lblWidth; QLabel *lblHeight; QLabel *lblWidthVal; QLabel *lblHeightVal; QMenuBar *menuBar; QMenu *menu_File; void setupUi(QMainWindow *splash) { if (splash->objectName().isEmpty()) splash->setObjectName(QString::fromUtf8("splash")); splash->setWindowModality(Qt::NonModal); splash->resize(172, 102); splash->setFocusPolicy(Qt::NoFocus); splash->setWindowTitle(QString::fromUtf8("")); #if QT_CONFIG(tooltip) splash->setToolTip(QString::fromUtf8("")); #endif // QT_CONFIG(tooltip) #if QT_CONFIG(statustip) splash->setStatusTip(QString::fromUtf8("")); #endif // QT_CONFIG(statustip) action_New = new QAction(splash); action_New->setObjectName(QString::fromUtf8("action_New")); action_Open = new QAction(splash); action_Open->setObjectName(QString::fromUtf8("action_Open")); action_Save = new QAction(splash); action_Save->setObjectName(QString::fromUtf8("action_Save")); centralwidget = new QWidget(splash); centralwidget->setObjectName(QString::fromUtf8("centralwidget")); centralwidget->setStyleSheet(QString::fromUtf8("background-color:#ff333333")); lblHdr = new QLabel(centralwidget); lblHdr->setObjectName(QString::fromUtf8("lblHdr")); lblHdr->setGeometry(QRect(7, 0, 161, 38)); lblHdr->setText(QString::fromUtf8("")); lblHdr->setPixmap(QPixmap(QString::fromUtf8(":/CMPY_LOGO"))); lblHdr->setScaledContents(false); lblHdr->setAlignment(Qt::AlignCenter); lblAppTitle = new QLabel(centralwidget); lblAppTitle->setObjectName(QString::fromUtf8("lblAppTitle")); lblAppTitle->setGeometry(QRect(8, 40, 161, 20)); lblAppTitle->setStyleSheet(QString::fromUtf8("color:#ffffffff;")); lblAppTitle->setAlignment(Qt::AlignCenter); lblAppTitle->setOpenExternalLinks(true); lblWidth = new QLabel(centralwidget); lblWidth->setObjectName(QString::fromUtf8("lblWidth")); lblWidth->setGeometry(QRect(8, 80, 91, 20)); lblWidth->setStyleSheet(QString::fromUtf8("color:#ffffffff;")); lblWidth->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter); lblHeight = new QLabel(centralwidget); lblHeight->setObjectName(QString::fromUtf8("lblHeight")); lblHeight->setGeometry(QRect(8, 60, 91, 20)); lblHeight->setStyleSheet(QString::fromUtf8("color:#ffffffff;")); lblHeight->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter); lblWidthVal = new QLabel(centralwidget); lblWidthVal->setObjectName(QString::fromUtf8("lblWidthVal")); lblWidthVal->setGeometry(QRect(110, 80, 60, 20)); lblWidthVal->setStyleSheet(QString::fromUtf8("color:#ffffffff;")); lblWidthVal->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); lblHeightVal = new QLabel(centralwidget); lblHeightVal->setObjectName(QString::fromUtf8("lblHeightVal")); lblHeightVal->setGeometry(QRect(110, 60, 60, 20)); lblHeightVal->setStyleSheet(QString::fromUtf8("color:#ffffffff;")); lblHeightVal->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); splash->setCentralWidget(centralwidget); menuBar = new QMenuBar(splash); menuBar->setObjectName(QString::fromUtf8("menuBar")); menuBar->setGeometry(QRect(0, 0, 172, 24)); menu_File = new QMenu(menuBar); menu_File->setObjectName(QString::fromUtf8("menu_File")); splash->setMenuBar(menuBar); menuBar->addAction(menu_File->menuAction()); menu_File->addAction(action_New); menu_File->addAction(action_Open); menu_File->addAction(action_Save); retranslateUi(splash); QMetaObject::connectSlotsByName(splash); } // setupUi void retranslateUi(QMainWindow *splash) { action_New->setText(QCoreApplication::translate("splash", "&New", nullptr)); action_Open->setText(QCoreApplication::translate("splash", "&Open", nullptr)); action_Save->setText(QCoreApplication::translate("splash", "&Save", nullptr)); #if QT_CONFIG(tooltip) lblAppTitle->setToolTip(QCoreApplication::translate("splash", "XML Multi-Platform Application Manager", nullptr)); #endif // QT_CONFIG(tooltip) lblAppTitle->setText(QCoreApplication::translate("splash", "XMLMPAM", nullptr)); lblWidth->setText(QCoreApplication::translate("splash", "Display width: ", nullptr)); lblHeight->setText(QCoreApplication::translate("splash", "Display height:", nullptr)); lblWidthVal->setText(QCoreApplication::translate("splash", "0", nullptr)); lblHeightVal->setText(QCoreApplication::translate("splash", "0", nullptr)); menu_File->setTitle(QCoreApplication::translate("splash", "&File", nullptr)); (void)splash; } // retranslateUi }; namespace Ui { class splash: public Ui_splash {}; } // namespace Ui QT_END_NAMESPACE #endif // UI_SPLASH_H
-
Finally fixed:
if ( mstrName.compare(clsXMLnode::mscszNodeAction) == 0 ) { Q_ASSERT_X(blnIsParentAMenu()==true, cpszClassConstr , "Actions only be used in a menu!"); Q_ASSERT_X(pobjParWidget!=nullptr, cpszClassConstr, "No menubar!"); const QString cstrShortcut(strGetAttribute(clsXMLnode::mscszAttrShortcut)) ,cstrText(strGetAttribute(clsXMLnode::mscszAttrText)) ,cstrTooltip(strGetAttribute(clsXMLnode::mscszAttrTooltip)); QMenu* pobjParentMenu(qobject_cast<QMenu*>(pobjParWidget)); Q_ASSERT_X(pobjParentMenu!=nullptr, cpszClassConstr, "Widget is not a menu!"); QWidget* pobjWindow(pobjParentMenu->window()); Q_ASSERT_X(pobjWindow!=nullptr, cpszClassConstr, "Cannot get window!"); QAction* pobjAction(new QAction(pobjWindow)); Q_ASSERT_X(pobjAction!=nullptr, cpszClassConstr, "Cannot create an action!"); pobjAction->setShortcut(QCoreApplication::translate("clsMainWnd" ,cstrShortcut.toLatin1() ,nullptr)); pobjAction->setText(cstrText); pobjAction->setToolTip(cstrTooltip); pobjParentMenu->addAction(pobjAction); } else if ( mstrName.compare(clsXMLnode::mscszNodeMenu) == 0 ) { Q_ASSERT_X(blnIsParentAMenuBar()==true, cpszClassConstr , "Menu's can only be added to a menu bar!"); const QString cstrShortcut(strGetAttribute(clsXMLnode::mscszAttrShortcut)) ,cstrText(strGetAttribute(clsXMLnode::mscszAttrText)) ,cstrTooltip(strGetAttribute(clsXMLnode::mscszAttrTooltip)); clsXMLnode* pobjMainWindowNode(nullptr); if ( pobjParent != nullptr && pobjParent->mpobjParent != nullptr ) { pobjMainWindowNode = pobjParent->mpobjParent; } Q_ASSERT_X(pobjMainWindowNode!=nullptr && pobjMainWindowNode->mpobjMainWindow!=nullptr, cpszClassConstr ,"Cannot get parent window!"); QMainWindow* pobjMainWindow(pobjMainWindowNode->mpobjMainWindow); QMenuBar* pobjMenuBar(pobjMainWindow->menuBar()); Q_ASSERT_X(pobjMenuBar!=nullptr, cpszClassConstr, "Cannot get menu bar!"); QMenu* pobjMenu(new QMenu(pobjMenuBar)); Q_ASSERT_X(pobjMenu!=nullptr, cpszClassConstr, "Cannot create menu!"); QAction* pobjAction(pobjMenu->menuAction()); Q_ASSERT_X(pobjAction!=nullptr, cpszClassConstr, "Cannot get action!"); pobjAction->setShortcut(cstrShortcut); pobjAction->setText(cstrText); pobjAction->setToolTip(cstrTooltip); pobjMenuBar->addAction(pobjAction); pobjMenu->show(); pobjMenuBar->show(); pobjWidget = pobjMenu; } else if ( mstrName.compare(clsXMLnode::mscszNodeMenuBar) == 0 ) { //Nothing required menubar should already be present in an instance of QMainWindow! }
-
@SPlatten said in QMenuBar, QMenu and QAction:
@Pl45m4 , what do you mean, "are you aware that you are working on the "toplevel" QMainWindow the whole time" ?
Are there two MainWindows involved in your app or is it just one?! Does this MainWindow have a
QMenuBar
already? Because your arent creating a new one