• 9663阅读
  • 5回复

[讨论]没有qpopupmenu.h文件,且出现各种no type的问题... [复制链接]

上一主题 下一主题
离线hmilyylimh
 
只看楼主 倒序阅读 楼主  发表于: 2011-05-02
1.这是我要编译的程序:
#include<qapplication.h>
#include<qpopupmenu.h>
#include<qpushbutton.h>
#include<qmenubar.h>
#include<qfont.h>
#include<qlineedit.h>
#include<qstring.h>

class MyMainWindow: public QWidget
{
    public:
        MyMainWindow();
    private:
        QPopupMenu *file;
        QPopupMenu *edit;
        QPopupMenu *tools;
        QPopupMenu *help;
        QMenuBar *menubar;
        QLineEdit *ledit;
};

MyMainWindow::MyMainWindow()
{
    setGeometry(100, 100, 300, 300);
    
    file=new QPopupMenu();
    file->insertItem("New");
    file->insertItem("Open");
    file->insertItem("Save");
    file->insertItem("Print");
    file->insertItem("Quit", qApp, SLOT(quit()));
    
    edit=new QPopupMenu();
    edit->insertItem("Select All", qApp, SLOT(selectAll()));
    edit->insertItem("Copy");
    edit->insertItem("Cut");
    edit->insertItem("Past");
    edit->insertItem("Delet");
    
    tools=new QPopupMenu();
    tools->insertItem("Fonts");
    tools->insertItem("Pargraph");
    tools->insertItem("Options");
    
    help= new QPopupMenu();
    help->insertItem("Menual List");
    help->insertItem("Our WebSite");
    help->insertItem("About This Program");
    
    menubar=new QMenuBar(this);
    menubar->insertItem("File", file);
    menubar->insertItem("Edit", edit);
    menubar->insertItem("Tools", tools);
    menubar->insertItem("Help", help);
    
    ledit =new QLineEdit(this);
    ledit->setText("Input Your Word Here");
    ledit->setFont(QFont("Times", 12, QFont::Bold) );
    ledit->setGeometry(20, 40, 300, 60);
};

int main(int argc, char **argv)
{
    QApplication a(argc, argv);
    MyMainWindow w;
    a.setMainWidget(&w);
    w.show();
    a.exec();
}

2.当我编译时候,执行qmake -project,然后qmake,然后make的时候,就出现以下的错误
hmily@xtu:~/文档/24hours_leaar_qt/mainwindow$ qmake -project
hmily@xtu:~/文档/24hours_leaar_qt/mainwindow$ qmake
hmily@xtu:~/文档/24hours_leaar_qt/mainwindow$ make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.7.2/mkspecs/linux-g++ -I. -I/usr/local/Trolltech/Qt-4.7.2/include/QtCore -I/usr/local/Trolltech/Qt-4.7.2/include/QtGui -I/usr/local/Trolltech/Qt-4.7.2/include -I. -I. -o mainwindow.o mainwindow.cpp
mainwindow.cpp:2:23: error: qpopupmenu.h: 没有那个文件或目录
mainwindow.cpp:14: error: ISO C++ forbids declaration of ‘QPopupMenu’ with no type
mainwindow.cpp:14: error: expected ‘;’ before ‘*’ token
mainwindow.cpp:15: error: ISO C++ forbids declaration of ‘QPopupMenu’ with no type
mainwindow.cpp:15: error: expected ‘;’ before ‘*’ token
mainwindow.cpp:16: error: ISO C++ forbids declaration of ‘QPopupMenu’ with no type
mainwindow.cpp:16: error: expected ‘;’ before ‘*’ token
mainwindow.cpp:17: error: ISO C++ forbids declaration of ‘QPopupMenu’ with no type
mainwindow.cpp:17: error: expected ‘;’ before ‘*’ token
mainwindow.cpp: In constructor ‘MyMainWindow::MyMainWindow()’:
mainwindow.cpp:26: error: ‘file’ was not declared in this scope
mainwindow.cpp:26: error: expected type-specifier before ‘QPopupMenu’
mainwindow.cpp:26: error: expected ‘;’ before ‘QPopupMenu’
mainwindow.cpp:33: error: ‘edit’ was not declared in this scope
mainwindow.cpp:33: error: expected type-specifier before ‘QPopupMenu’
mainwindow.cpp:33: error: expected ‘;’ before ‘QPopupMenu’
mainwindow.cpp:40: error: ‘tools’ was not declared in this scope
mainwindow.cpp:40: error: expected type-specifier before ‘QPopupMenu’
mainwindow.cpp:40: error: expected ‘;’ before ‘QPopupMenu’
mainwindow.cpp:45: error: ‘help’ was not declared in this scope
mainwindow.cpp:45: error: expected type-specifier before ‘QPopupMenu’
mainwindow.cpp:45: error: expected ‘;’ before ‘QPopupMenu’
mainwindow.cpp:51: error: ‘class QMenuBar’ has no member named ‘insertItem’
mainwindow.cpp:52: error: ‘class QMenuBar’ has no member named ‘insertItem’
mainwindow.cpp:53: error: ‘class QMenuBar’ has no member named ‘insertItem’
mainwindow.cpp:54: error: ‘class QMenuBar’ has no member named ‘insertItem’
mainwindow.cpp: In function ‘int main(int, char**)’:
mainwindow.cpp:66: error: ‘class QApplication’ has no member named ‘setMainWidget’
make: *** [mainwindow.o] 错误 1

这个东西老是报错,我真的就不明白了,同样是Qt4版本的,为什么我的出现这么多的问题,我解决不了了,由于我是初学者,很多的问题我可能说不到点上,还请各位大侠谅解,帮帮忙,帮我解决这个问题....
非常感谢...非常感谢...非常感谢...非常感谢...非常感谢...非常感谢...非常感谢...非常感谢...
离线dbzhang800

只看该作者 1楼 发表于: 2011-05-02
如果你用Qt4环境,就写Qt4的程序!

如果写Qt3(包括)之前的程序,就不要装Qt4!!
离线hmilyylimh
只看该作者 2楼 发表于: 2011-05-02
啊?这个两个版本不是大体的都是一样的吗?
离线hmilyylimh
只看该作者 3楼 发表于: 2011-05-02
那请问一下 《24小时学通qt编程》这本电子书是qt几的啊?我最近老是编一个错一个,弄的我都没信心学下去了...
离线dbzhang800

只看该作者 4楼 发表于: 2011-05-02
引用第3楼hmilyylimh于2011-05-02 08:01发表的  :
那请问一下 《24小时学通qt编程》这本电子书是qt几的啊?我最近老是编一个错一个,弄的我都没信心学下去了...


汗,竟然是2000年的书,当时Qt3都还没出来。

你就是看Qt自带的manual也比它强吧? 没有任何一本书能取代Qt的manual

http://developer.qt.nokia.com/books
离线roywillow

只看该作者 5楼 发表于: 2011-05-02
引用第2楼hmilyylimh于2011-05-02 08:00发表的  :
啊?这个两个版本不是大体的都是一样的吗?

〇.〇
如果说大体一样的话,为啥Qt4很多东西都要额外提供Qt3的支持……
专业维修核潜艇,回收二手航母、二手航天飞机,大修核反应堆,拆洗导弹发动机更换机油,无人侦察机手动挡改自动,航天飞机保养换三滤,飞碟外太空年检 ,各型号导弹加装迎宾踏板,高空作业擦洗卫星表面除尘、打蜡及抛光,东风全系列巡航导弹。并提供原子对撞机。量大从优,有正规发票。
快速回复
限100 字节
 
上一个 下一个