0

I am a new to Qt. A little bit confused with ui, especially uic.

I have created a project to practice Qt: https://github.com/eala/mediaAlgoManager

However, I can't see the menubar when I run it as following:

enter image description here

The application can't get correct menu bar. But if I switch to any other applications, and then switch back, it will work correctly.

enter image description here

I don't know what happened! I have searched some resources, like Qt menubar not showing.

And I think there are some conflicts that there are some GUI design from Qt Designer and some come from codes. I have tried two ways as follows, but still not work.

  1. remove setActionMenuBar() function in analyzeGoldenWindow.cpp (add menu bar by codes)
  2. remove or add just in front of status bar in analyzeGoldenWindow.ui

But...the issue is still there....

Community
  • 1
  • 1
eala
  • 23
  • 6
  • Looks like you are creating the menu bar from code, can you post your code? – Anton Poznyakovskiy Dec 29 '14 at 16:01
  • in mainWindow constructor, I use following: mMenuBar = new QMenuBar(this); mMenuBar->setNativeMenuBar(true); mFileMenu = mMenuBar->addMenu(tr("&File")); mNewFileAction = new QAction(tr("&New ..."), this); mFileMenu->addAction(mNewFileAction); connect(mNewFileAction, SIGNAL(triggered()), this, SLOT(newFile())); – eala Dec 29 '14 at 16:13
  • complete codes can be download from https://github.com/eala/mediaAlgoManager – eala Dec 29 '14 at 16:14

1 Answers1

0

Call setMenuBar(mMenuBar) as the last action in analyzeGoldenWindow::setActionMenuBar(). If that fails, try calling setupUi before you create the menu.

Anton Poznyakovskiy
  • 2,109
  • 1
  • 20
  • 38
  • still not works...I am not sure what happened. How should I test after I modify some codes every time? I can't find ui_analyzegoldenwindow.h in Finder. So I always right click on the project: (1) Run qMake (2) Rebuild. However, I can't find the proper way to resolve this. I even delete *.pro.user each time. – eala Dec 29 '14 at 16:44
  • it seems not working. Maybe the problem exists when opencv createWindow or something else. I have tried menu role as shown in [link](http://qt-project.org/forums/viewthread/14610/0) which not working either. – eala Dec 29 '14 at 17:16
  • I'll try running your project a bit later. – Anton Poznyakovskiy Dec 29 '14 at 17:18
  • Thanks a lot in advance. In the beginning, I selected template "Dialog without buttons" to implement and later I changed by codes to inherit mainWindow. I am not sure if it is related. I created a new mainWindow project and diff with two *.ui files, but nothing I found... – eala Dec 29 '14 at 23:58