Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Menu bar does not show up

    General and Desktop
    3
    12
    3793
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      SahamGhazavi last edited by

      Hi

      I am following tutorials on youtube. My form has Manu bar and toolbar. I have created one menu named File and under that I have submenu called New Window. I also added actionNew_Window to the toolbar. When I run the program, the toolbar is there but I dont see my menu.

      Any idea?

      1 Reply Last reply Reply Quote 0
      • Q
        qxoz last edited by

        Hi!
        Which tutorial do you use?
        Show us the code.

        1 Reply Last reply Reply Quote 0
        • S
          SahamGhazavi last edited by

          http://www.youtube.com/watch?v=wUH_gu2HdQE

          Thank you

          1 Reply Last reply Reply Quote 0
          • Q
            qxoz last edited by

            It is very strange if example not works as expected. Did you make any changes in code from example?

            1 Reply Last reply Reply Quote 0
            • S
              SahamGhazavi last edited by

              Nope. I even started the new project and just created one File menu with no submenu. Still does not show up when I run it!!

              1 Reply Last reply Reply Quote 0
              • R
                raf924 last edited by

                Check if the menu bar is visible with the isVisible() function. You never know

                1 Reply Last reply Reply Quote 0
                • S
                  SahamGhazavi last edited by

                  There is not visible property for the menu bar or I cannot find it.
                  I even add this on main window constructor:
                  ui->menuBar->setVisible(true);

                  but didnt help

                  1 Reply Last reply Reply Quote 0
                  • R
                    raf924 last edited by

                    There is : ui->menuBar->isVisible()
                    Just out of curiosity : what version of Qt are you using?

                    1 Reply Last reply Reply Quote 0
                    • S
                      SahamGhazavi last edited by

                      Qt Creator 2.7.0
                      Based on Qt 5.0.2 (64 bit)

                      Built on Apr 9 2013 at 09:31:19

                      isVisible() just checks for visibility but I wanted to set the visibility :)

                      1 Reply Last reply Reply Quote 0
                      • S
                        SahamGhazavi last edited by

                        If the following always puts NO in the text filed
                        if(ui->menuBar->isVisible())
                        ui->plainTextEdit->setPlainText("YES");
                        else
                        ui->plainTextEdit->setPlainText("No");

                        1 Reply Last reply Reply Quote 0
                        • Q
                          qxoz last edited by

                          Can you post your project?

                          1 Reply Last reply Reply Quote 0
                          • S
                            SahamGhazavi last edited by

                            mainwindow.h
                            @
                            #ifndef MAINWINDOW_H
                            #define MAINWINDOW_H

                            #include <QMainWindow>
                            #include "mydialog.h"
                            namespace Ui {
                            class MainWindow;
                            }

                            class MainWindow : public QMainWindow
                            {
                            Q_OBJECT

                            public:
                            explicit MainWindow(QWidget *parent = 0);
                            ~MainWindow();

                            private slots:
                            void on_actionNew_Window_triggered();

                            private:
                            Ui::MainWindow *ui;
                            MyDialog *mDialog;
                            };

                            #endif // MAINWINDOW_H
                            @
                            @
                            mydialog.h

                            #ifndef MYDIALOG_H
                            #define MYDIALOG_H

                            #include <QDialog>

                            namespace Ui {
                            class MyDialog;
                            }

                            class MyDialog : public QDialog
                            {
                            Q_OBJECT

                            public:
                            explicit MyDialog(QWidget *parent = 0);
                            ~MyDialog();

                            private:
                            Ui::MyDialog *ui;
                            };

                            #endif // MYDIALOG_H
                            @
                            @
                            main.cpp

                            #include "mainwindow.h"
                            #include <QApplication>

                            int main(int argc, char *argv[])
                            {
                            QApplication a(argc, argv);
                            MainWindow w;
                            w.show();

                            return a.exec();
                            }
                            @
                            @
                            mainwindow.cpp

                            #include "mainwindow.h"
                            #include "ui_mainwindow.h"
                            #include "mydialog.h"
                            MainWindow::MainWindow(QWidget *parent) :
                            QMainWindow(parent),
                            ui(new Ui::MainWindow)
                            {

                            ui->setupUi(this);
                            //setCentralWidget(ui->plainTextEdit);
                            ui->menuBar->setVisible(true);
                            if(ui->menuBar->isVisible())
                            ui->plainTextEdit->setPlainText("IS");
                            else
                            ui->plainTextEdit->setPlainText("No");

                            }

                            MainWindow::~MainWindow()
                            {
                            delete ui;
                            }

                            void MainWindow::on_actionNew_Window_triggered()
                            {
                            mDialog = new MyDialog(this);
                            mDialog->show();
                            //mDialog.setModal(true);
                            //mDialog.exec();
                            }
                            @
                            @
                            mydialog.cpp

                            #include "mydialog.h"
                            #include "ui_mydialog.h"

                            MyDialog::MyDialog(QWidget *parent) :
                            QDialog(parent),
                            ui(new Ui::MyDialog)
                            {
                            ui->setupUi(this);
                            }

                            MyDialog::~MyDialog()
                            {
                            delete ui;
                            }
                            @
                            @
                            mainwindow.h

                            Thanks

                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post