Qt menuBar()错误 [英] Qt menuBar() Error

查看:405
本文介绍了Qt menuBar()错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习Qt4并通过他们的教程进行学习.

I'm in the process of learning Qt4 and working through their tutorials.

在本教程中:

http://doc.trolltech.com/4.5/mainwindows -menus-mainwindow-cpp.html

它们具有以下代码:

fileMenu = menuBar()->addMenu(tr("&File"));

这会导致编译器抛出此错误

which causes the compiler to throw this error


g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o main.o main.cpp
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o MainWindow.o MainWindow.cpp
MainWindow.cpp: In member function ‘void MainWindow::createMenus()’:
MainWindow.cpp:56: error: ‘((MainWindow*)this)->MainWindow::menuBar’ cannot be used as a function
MainWindow.cpp:61: error: ‘((MainWindow*)this)->MainWindow::menuBar’ cannot be used as a function
make: *** [MainWindow.o] Error 1

有人知道我该如何解决吗?

Does anyone know how I can fix this?

添加了带有g ++的完整错误消息

Added full error Message with g++

推荐答案

由于某些原因,QMainWindow无法正确设置.这是通过调用基类构造函数来解决的.

For some reason QMainWindow was not getting setting up correctly. This was fixed by calling the base class constructor.

这篇关于Qt menuBar()错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆