• 5355阅读
  • 3回复

开发文本编辑器的程序 [复制链接]

上一主题 下一主题
离线计科院
 
只看楼主 倒序阅读 楼主  发表于: 2009-03-15
以下是源代码
#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();
}


在运行了make命令后出现了一系列的错误
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/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I. -o file.o file.cpp
file.cpp:2:23: error: qpopupmenu.h: 没有该文件或目录
file.cpp:14: 错误: ISO C++ 不允许声明无类型的‘QPopupMenu’
file.cpp:14: 错误: expected ‘;’ before ‘*’ token
file.cpp:15: 错误: ISO C++ 不允许声明无类型的‘QPopupMenu’
file.cpp:15: 错误: expected ‘;’ before ‘*’ token
file.cpp:16: 错误: ISO C++ 不允许声明无类型的‘QPopupMenu’
file.cpp:16: 错误: expected ‘;’ before ‘*’ token
file.cpp:17: 错误: ISO C++ 不允许声明无类型的‘QPopupMenu’
file.cpp:17: 错误: expected ‘;’ before ‘*’ token
file.cpp: In constructor ‘MyMainWindow::MyMainWindow()’:
file.cpp:26: 错误: ‘file’在此作用域中尚未声明
file.cpp:26: 错误: expected type-specifier before ‘QPopupMenu’
file.cpp:26: 错误: expected `;' before ‘QPopupMenu’
file.cpp:33: 错误: ‘edit’在此作用域中尚未声明
file.cpp:33: 错误: expected type-specifier before ‘QPopupMenu’
file.cpp:33: 错误: expected `;' before ‘QPopupMenu’
file.cpp:40: 错误: ‘tools’在此作用域中尚未声明
file.cpp:40: 错误: expected type-specifier before ‘QPopupMenu’
file.cpp:40: 错误: expected `;' before ‘QPopupMenu’
file.cpp:45: 错误: ‘help’在此作用域中尚未声明
file.cpp:45: 错误: expected type-specifier before ‘QPopupMenu’
file.cpp:45: 错误: expected `;' before ‘QPopupMenu’
file.cpp:51: 错误: ‘class QMenuBar’没有名为‘insertItem’的成员
file.cpp:52: 错误: ‘class QMenuBar’没有名为‘insertItem’的成员
file.cpp:53: 错误: ‘class QMenuBar’没有名为‘insertItem’的成员
file.cpp:54: 错误: ‘class QMenuBar’没有名为‘insertItem’的成员
file.cpp: In function ‘int main(int, char**)’:
file.cpp:66: 错误: ‘class QApplication’没有名为‘setMainWidget’的成员
make: *** [file.o] 错误 1


请各位大哥们帮帮忙

离线计科院
只看该作者 1楼 发表于: 2009-03-15
请大家帮帮忙额55
只看该作者 2楼 发表于: 2009-03-15
qt3的代码拿qt4的库编译了,不出错就奇怪了
离线计科院
只看该作者 3楼 发表于: 2009-03-16
引用第2楼都市无名者于2009-03-15 23:27发表的  :
qt3的代码拿qt4的库编译了,不出错就奇怪了


兄弟 谢谢额。。。。万分感谢!!!!!
快速回复
限100 字节
 
上一个 下一个