• 10372阅读
  • 3回复

【提问】新手请教各位一个问题……各位老大请进 [复制链接]

上一主题 下一主题
离线guazi111
 

只看楼主 倒序阅读 楼主  发表于: 2006-02-26
才准备学QT,但是第一个程序就卡住了……(《24小时学通QT》中的第一个例子)


#include <qapplication.h>
#include <qwidget.h>
#include <qpushbutton.h>

int main(int argc,char **argv)
{
    QApplication a(argc,argv);

QWidget mainwindow;
mainwindow.setMinimumSize(200,100);
mainwindow.setMaxmumSize(200,100);

QPushButton helloworld("Hello World!",&mainwindow);
helloworld.setGeometry(20,20,160,60);

a.setMainWidget(&mainwindow);
mianwindow.show();
return a.exec();
}

之后qmake -project
qmake都没事
make之后提示:
[root@MagicLinux h]# make
g++ -c -pipe -Wall -W -O2 -g -pipe -D_FORTIFY_SOURCE=2 -m32 -march=i686 -mcpu=i686 -mtune=i686 -DQT_NO_DEBUG -DQT_SHARED -DQT_THREAD_SUPPORT -I/usr/lib/qt-3.3/mkspecs/default -I. -I. -Isrc -I/usr/lib/qt-3.3/include -o h.o src/h.cpp
src/h.cpp: In function `int main(int, char**)':
src/h.cpp:31: error: 'class QWidget' has no member named 'setMaxmumSize'
src/h.cpp:37: error: `mianwindow' undeclared (first use this function)
src/h.cpp:37: error: (Each undeclared identifier is reported only once for each function it appears in.)
make: *** [h.o] 错误 1
[root@MagicLinux h]#

我使用的是magiclinux(一个很优秀的国人制作的社区发行版)自带的qt3.3,《24小时学通qt》中是以qt2作为讲解的,是不是因为版本变化的原因导致一些类发生了变化所以不行??那么各位老大们能推荐几本适合初学者的qt3的中文书籍么??在下英文不好……

多谢各位
[ 此贴被XChinux在2006-02-25 18:35重新编辑 ]
离线XChinux

只看该作者 1楼 发表于: 2006-02-26

[root@MagicLinux h]# make
g++ -c -pipe -Wall -W -O2 -g -pipe -D_FORTIFY_SOURCE=2 -m32 -march=i686 -mcpu=i686 -mtune=i686 -DQT_NO_DEBUG -DQT_SHARED -DQT_THREAD_SUPPORT -I/usr/lib/qt-3.3/mkspecs/default -I. -I. -Isrc -I/usr/lib/qt-3.3/include -o h.o src/h.cpp
src/h.cpp: In function `int main(int, char**)':
src/h.cpp:31: error: 'class QWidget' has no member named 'setMaxmumSize'
src/h.cpp:37: error: `mianwindow' undeclared (first use this function)
src/h.cpp:37: error: (Each undeclared identifier is reported only once for each function it appears in.)
make: *** [h.o] 错误 1
[root@MagicLinux h]#


这不是人家编译器都告诉过你了么?QWidget类里没有setMaxmumSize(应该是setMaximumSizze,你拼写错了), mianwindow没有被声明过(是mainwindow,你又拼写错了)
。。。。。。。。。。。。。。。

你说该怎么说你?
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
离线guazi111

只看该作者 2楼 发表于: 2006-02-26
啊,抱歉……
在linux下看超星的电子书看的头都晕了……
多谢多谢

不过有什么qt3的书么》???

现在变成这样子了……


[root@MagicLinux on]# make
g++ -o on main.o on.o moc_on.o   -L/usr/lib/qt-3.3/lib -L/usr/X11R6/lib -lqt-mt -lXext -lX11 -lm
on.o: In function `main':
/usr/lib/qt-3.3/include/qglist.h:151: multiple definition of `main'
main.o:/usr/lib/qt-3.3/include/qglist.h:151: first defined here
/usr/bin/ld: Warning: size of symbol `main' changed from 499 in main.o to 425 in on.o
main.o: In function `main':
main.cpp:(.text+0x6a): undefined reference to `KAboutData::KAboutData(char const*, char const*, char const*, char const*, int, char const*, char const*, char const*, char const*)'
main.cpp:(.text+0x90): undefined reference to `KAboutData::addAuthor(char const*, char const*, char const*, char const*)'
main.cpp:(.text+0xac): undefined reference to `KCmdLineArgs::init(int, char**, KAboutData const*, bool)'
main.cpp:(.text+0xca): undefined reference to `KCmdLineArgs::addCmdLineOptions(KCmdLineOptions const*, char const*, char const*, char const*)'
main.cpp:(.text+0xea): undefined reference to `KApplication::KApplication(bool, bool)'
main.cpp:(.text+0x100): undefined reference to `KMainWindow::canBeRestored(int)'
main.cpp:(.text+0x11e): undefined reference to `on::on()'
main.cpp:(.text+0x133): undefined reference to `KMainWindow::restore(int, bool)'
main.cpp:(.text+0x13c): undefined reference to `KMainWindow::canBeRestored(int)'
main.cpp:(.text+0x148): undefined reference to `KAboutData::~KAboutData()'
main.cpp:(.text+0x15c): undefined reference to `KCmdLineArgs::parsedArgs(char const*)'
main.cpp:(.text+0x174): undefined reference to `on::on()'
main.cpp:(.text+0x199): undefined reference to `KCmdLineArgs::clear()'
main.cpp:(.text+0x1b7): undefined reference to `KApplication::~KApplication()'
main.cpp:(.text+0x1bf): undefined reference to `KAboutData::~KAboutData()'
main.cpp:(.text+0x1de): undefined reference to `KApplication::~KApplication()'
moc_on.o: In function `on::staticMetaObject()':
src/moc_on.cpp:54: undefined reference to `KMainWindow::staticMetaObject()'
moc_on.o: In function `on::qt_invoke(int, QUObject*)':
src/moc_on.cpp:77: undefined reference to `KMainWindow::qt_invoke(int, QUObject*)'
moc_on.o: In function `on::qt_emit(int, QUObject*)':
src/moc_on.cpp:82: undefined reference to `KMainWindow::qt_emit(int, QUObject*)'
moc_on.o: In function `on::qt_property(int, int, QVariant*)':
src/moc_on.cpp:88: undefined reference to `KMainWindow::qt_property(int, int, QVariant*)'
moc_on.o: In function `on::qt_cast(char const*)':
src/moc_on.cpp:72: undefined reference to `KMainWindow::qt_cast(char const*)'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x8): undefined reference to `typeinfo for KMainWindow'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x10): undefined reference to `KMainWindow::className() const'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x14): undefined reference to `KMainWindow::qt_cast(char const*)'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x18): undefined reference to `KMainWindow::qt_invoke(int, QUObject*)'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x1c): undefined reference to `KMainWindow::qt_emit(int, QUObject*)'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x20): undefined reference to `KMainWindow::qt_property(int, int, QVariant*)'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x24): undefined reference to `KMainWindow::~KMainWindow()'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x28): undefined reference to `KMainWindow::~KMainWindow()'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x4c): undefined reference to `KMainWindow::childEvent(QChildEvent*)'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0xa4): undefined reference to `KMainWindow::setCaption(QString const&)'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0xa8): undefined reference to `KMainWindow::setIcon(QPixmap const&)'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0xc8): undefined reference to `KMainWindow::show()'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0xcc): undefined reference to `KMainWindow::hide()'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x14c): undefined reference to `KMainWindow::paintEvent(QPaintEvent*)'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x154): undefined reference to `KMainWindow::resizeEvent(QResizeEvent*)'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x158): undefined reference to `KMainWindow::closeEvent(QCloseEvent*)'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x224): undefined reference to `KMainWindow::guiFactory()'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x228): undefined reference to `KMainWindow::finalizeGUI(KXMLGUIClient*)'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x22c): undefined reference to `KMainWindow::setCaption(QString const&, bool)'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x230): undefined reference to `KMainWindow::setPlainCaption(QString const&)'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x234): undefined reference to `KMainWindow::slotStateChanged(QString const&)'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x238): undefined reference to `KMainWindow::queryExit()'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x23c): undefined reference to `KMainWindow::queryClose()'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x248): undefined reference to `KMainWindow::saveGlobalProperties(KConfig*)'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x24c): undefined reference to `KMainWindow::readGlobalProperties(KConfig*)'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x250): undefined reference to `KMainWindow::showAboutApplication()'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x254): undefined reference to `KMainWindow::virtual_hook(int, void*)'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x298): undefined reference to `typeinfo for KMainWindow'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x29c): undefined reference to `virtual thunk to KMainWindow::~KMainWindow()'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x2a0): undefined reference to `virtual thunk to KMainWindow::~KMainWindow()'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x2a4): undefined reference to `KXMLGUIClient::action(QDomElement const&) const'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x2a8): undefined reference to `KXMLGUIClient::actionCollection() const'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x2ac): undefined reference to `KXMLGUIClient::instance() const'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x2b0): undefined reference to `KXMLGUIClient::domDocument() const'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x2b4): undefined reference to `KXMLGUIClient::xmlFile() const'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x2b8): undefined reference to `KXMLGUIClient::localXMLFile() const'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x2bc): undefined reference to `KXMLGUIClient::setInstance(KInstance*)'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x2c0): undefined reference to `KXMLGUIClient::setXMLFile(QString const&, bool, bool)'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x2c4): undefined reference to `KXMLGUIClient::setLocalXMLFile(QString const&)'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x2c8): undefined reference to `KXMLGUIClient::setXML(QString const&, bool)'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x2cc): undefined reference to `KXMLGUIClient::setDOMDocument(QDomDocument const&, bool)'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x2d0): undefined reference to `KXMLGUIClient::conserveMemory()'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x2d4): undefined reference to `KXMLGUIClient::stateChanged(QString const&, KXMLGUIClient::ReverseStateChange)'
moc_on.o:(.gnu.linkonce.r._ZTC2on0_11KMainWindow+0x2d8): undefined reference to `virtual thunk to KMainWindow::virtual_hook(int, void*)'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x24): undefined reference to `on::~on()'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x28): undefined reference to `on::~on()'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x4c): undefined reference to `KMainWindow::childEvent(QChildEvent*)'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0xa4): undefined reference to `KMainWindow::setCaption(QString const&)'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0xa8): undefined reference to `KMainWindow::setIcon(QPixmap const&)'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0xc8): undefined reference to `KMainWindow::show()'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0xcc): undefined reference to `KMainWindow::hide()'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x14c): undefined reference to `KMainWindow::paintEvent(QPaintEvent*)'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x154): undefined reference to `KMainWindow::resizeEvent(QResizeEvent*)'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x158): undefined reference to `KMainWindow::closeEvent(QCloseEvent*)'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x224): undefined reference to `KMainWindow::guiFactory()'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x228): undefined reference to `KMainWindow::finalizeGUI(KXMLGUIClient*)'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x22c): undefined reference to `KMainWindow::setCaption(QString const&, bool)'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x230): undefined reference to `KMainWindow::setPlainCaption(QString const&)'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x234): undefined reference to `KMainWindow::slotStateChanged(QString const&)'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x238): undefined reference to `KMainWindow::queryExit()'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x23c): undefined reference to `KMainWindow::queryClose()'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x248): undefined reference to `KMainWindow::saveGlobalProperties(KConfig*)'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x24c): undefined reference to `KMainWindow::readGlobalProperties(KConfig*)'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x250): undefined reference to `KMainWindow::showAboutApplication()'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x254): undefined reference to `KMainWindow::virtual_hook(int, void*)'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x260): undefined reference to `non-virtual thunk to on::~on()'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x264): undefined reference to `non-virtual thunk to on::~on()'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x294): undefined reference to `non-virtual thunk to on::~on()'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x298): undefined reference to `non-virtual thunk to on::~on()'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x29c): undefined reference to `KXMLGUIBuilder::containerTags() const'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x2a0): undefined reference to `KXMLGUIBuilder::createContainer(QWidget*, int, QDomElement const&, int&)'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x2a4): undefined reference to `KXMLGUIBuilder::removeContainer(QWidget*, QWidget*, QDomElement&, int)'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x2a8): undefined reference to `KXMLGUIBuilder::customTags() const'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x2ac): undefined reference to `KXMLGUIBuilder::createCustomElement(QWidget*, int, QDomElement const&)'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x2b0): undefined reference to `KXMLGUIBuilder::removeCustomElement(QWidget*, int)'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x2b4): undefined reference to `non-virtual thunk to KMainWindow::finalizeGUI(KXMLGUIClient*)'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x2b8): undefined reference to `non-virtual thunk to KMainWindow::virtual_hook(int, void*)'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x300): undefined reference to `virtual thunk to on::~on()'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x304): undefined reference to `virtual thunk to on::~on()'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x308): undefined reference to `KXMLGUIClient::action(QDomElement const&) const'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x30c): undefined reference to `KXMLGUIClient::actionCollection() const'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x310): undefined reference to `KXMLGUIClient::instance() const'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x314): undefined reference to `KXMLGUIClient::domDocument() const'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x318): undefined reference to `KXMLGUIClient::xmlFile() const'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x31c): undefined reference to `KXMLGUIClient::localXMLFile() const'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x320): undefined reference to `KXMLGUIClient::setInstance(KInstance*)'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x324): undefined reference to `KXMLGUIClient::setXMLFile(QString const&, bool, bool)'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x328): undefined reference to `KXMLGUIClient::setLocalXMLFile(QString const&)'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x32c): undefined reference to `KXMLGUIClient::setXML(QString const&, bool)'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x330): undefined reference to `KXMLGUIClient::setDOMDocument(QDomDocument const&, bool)'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x334): undefined reference to `KXMLGUIClient::conserveMemory()'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x338): undefined reference to `KXMLGUIClient::stateChanged(QString const&, KXMLGUIClient::ReverseStateChange)'
moc_on.o:(.gnu.linkonce.r._ZTV2on+0x33c): undefined reference to `virtual thunk to KMainWindow::virtual_hook(int, void*)'
moc_on.o:(.gnu.linkonce.r._ZTI2on+0x8): undefined reference to `typeinfo for KMainWindow'
moc_on.o: In function `KMainWindow::metaObject() const':
/usr/include/kmainwindow.h:101: undefined reference to `KMainWindow::staticMetaObject()'
collect2: ld returned 1 exit status
make: *** [on] 错误 1
[root@MagicLinux on]#  

咋回事??
[ 此贴被guazi111在2006-02-25 19:40重新编辑 ]
离线lcc_zjut

只看该作者 3楼 发表于: 2006-03-03
老大,你看的这本书是不是基于KDE的啊?
你写的东东用到了KDE的系统函数库,你没有在KDE环境下,当然会报错了!!!!!!!!!
快速回复
限100 字节
 
上一个 下一个