Adding Menu Bar with no result..
-
Works fine for me:
#include <QtWidgets> int main(int argc, char *argv[]) { QApplication::setAttribute(Qt::AA_DontUseNativeDialogs); QMainWindow mainWin; mainWin.menuBar()->addMenu(new QMenu("Preferences")); mainWin.show(); return app.exec(); }
-
Please do not post images but actual text - it's unreadable.
What I can see is that you create a second QMenuBar for unknown reasons. Use the one from QMainWindow or properly set the QMenuBar to the QMainWindow. -
The image posted is perfectly readable and sufficient to illustrate the problem. Why do you question OP reason for adding the second menubar ? His reasoning is immaterial to help resolve the issue. Perhaps edit your post to concentrate / expand on your valid , axtual solutions . ( I wrote this while the OP replied ).
-
@AnneRanch said in Adding Menu Bar with no result..:
Why do you question OP reason for adding the second menubar
Because he does and I also properly explained what's wrong - sorry if it's to complicated for you to understand.
-
Thanks for answering..
I have tryied using the default menuBar(),
Header:
#ifndef WPRINCIPAL_H #define WPRINCIPAL_H #include <QMainWindow> class QMenu; class QAction; class wprincipal : public QMainWindow{ Q_OBJECT private: QMenu* menu0 {nullptr}; //File... QAction* act00 {nullptr}; //File -> Preferences... protected slots: void ontrigger_act00(); public: explicit wprincipal(QWidget* _p = nullptr); ~wprincipal(){} }; #endif // WPRINCIPAL_H
Source:
#include "wprincipal.h" #include <QMenuBar> #include <QMenu> wprincipal::wprincipal(QWidget* _p) : QMainWindow(_p){ act00 = new QAction; act00->setText("Preferences"); menu0 = new QMenu; menuBar()->addMenu(menu0); menu0->addAction(act00); } void wprincipal::ontrigger_act00(){ }
...but still something happens that is not being shown:
-
Works fine for me:
#include <QtWidgets> int main(int argc, char *argv[]) { QApplication::setAttribute(Qt::AA_DontUseNativeDialogs); QMainWindow mainWin; mainWin.menuBar()->addMenu(new QMenu("Preferences")); mainWin.show(); return app.exec(); }
-
@1XU7 : I also don't see a big difference so can't tell what's wrong.
-