有人帮我没????

喜歡程式設計嗎?想要一窺 KDE/Qt 程式設計的奧秘嗎?想要
學習 X Window 上的視窗程式設計嗎?歡迎各類關於 KDE/Qt、Qtopia、Qt/Embedded、QSA、PyQt 等各類心得討論。

版主: AceLan, Franklin

有人帮我没????

文章民国陪都 » 週二 3月 29, 2005 7:14 pm

我编了下官方网站上面的实例1-6 ,前面的都没问题,可编到6的时候就遍不下去了!!各位帮我看看????

具体的代码在后面

××××××××××××××××××××××××××××××
错误信息:


g++ -c -pipe -DQWS -fno-exceptions -fno-rtti -Wall -W -O2 -fno-default-inline -DNO_DEBUG -I/qt/qt/include -o hello.o hello.cpp
hello.cpp:1: `qapplication' was not declared(宣布) in this scope(作用域)
In file included from /qt/qt/include/qobjectdefs.h:42,
from /qt/qt/include/qwindowdefs.h:43,
from /qt/qt/include/qwidget.h:42,

from /qt/qt/include/qbutton.h:42,

from /qt/qt/include/qpushbutton.h:42,
from hello.cpp:2:

/qt/qt/include/qglobal.h:382: syntax error before `typedef'

/qt/qt/include/qglobal.h:387: syntax error before `*' token

In file included from /qt/qt/include/qwindowdefs.h:44,
from /qt/qt/include/qwidget.h:42,
from /qt/qt/include/qbutton.h:42,
from /qt/qt/include/qpushbutton.h:42,
from hello.cpp:2:
/qt/qt/include/qstring.h:59: parse(分析) error before `c'

/qt/qt/include/qstring.h:60: parse error before `c'
/qt/qt/include/qstring.h:166: syntax(语法) error before `&' token

/qt/qt/include/qstring.h: In member function `char QChar::latin1() const':
/qt/qt/include/qstring.h:149: `rw' undeclared(未宣布) (first use this function)
/qt/qt/include/qstring.h:149: (Each undeclared identifier(标识符) is reported only once

for each function it appears in.)
/qt/qt/include/qstring.h:149: `cl' undeclared (first use this function)

/qt/qt/include/qstring.h: At global scope(全作用域):
/qt/qt/include/qstring.h:167: ISO C++ forbids defining types within return type
/qt/qt/include/qstring.h:167: syntax error before `&' token
/qt/qt/include/qstring.h:168: parse error before `)' token
/qt/qt/include/qstring.h:169: parse error before `)' token
/qt/qt/include/qstring.h: In function `bool networkOrdered()':
/qt/qt/include/qstring.h:171: `net_ordered' undeclared (first use this
function)
/qt/qt/include/qstring.h: At global scope:
/qt/qt/include/qstring.h:173: friend declaration not in class definition
/qt/qt/include/qstring.h:174: friend declaration not in class definition
/qt/qt/include/qstring.h:175: friend declaration not in class definition
/qt/qt/include/qstring.h:176: friend declaration not in class definition
/qt/qt/include/qstring.h:177: friend declaration not in class definition
/qt/qt/include/qstring.h:178: friend declaration not in class definition
/qt/qt/include/qstring.h:179: friend declaration not in class definition
/qt/qt/include/qstring.h:180: friend declaration not in class definition
/qt/qt/include/qstring.h:181: friend declaration not in class definition
/qt/qt/include/qstring.h:183: parse error before `private'
/qt/qt/include/qstring.h:188: 'uchar' is used as a type, but is not defined as
a type.
/qt/qt/include/qstring.h:192: `net_ordered' used prior to declaration
/qt/qt/include/qstring.h:202: parse error before `}' token
/qt/qt/include/qstring.h: In constructor `QChar::QChar(char)':
/qt/qt/include/qstring.h:213: `uchar' undeclared (first use this function)
/qt/qt/include/qstring.h:213: parse error before `;' token
/qt/qt/include/qstring.h: At global scope:
/qt/qt/include/qstring.h:218: parse error before `c'
/qt/qt/include/qstring.h:220: ISO C++ forbids declaration of `cl' with no type
/qt/qt/include/qstring.h:220: `int cl' used prior to declaration
/qt/qt/include/qstring.h:220: `c' was not declared in this scope
/qt/qt/include/qstring.h:224: parse error before `}' token
/qt/qt/include/qstring.h:225: parse error before `c'
/qt/qt/include/qstring.h:227: ISO C++ forbids declaration of `cl' with no type
/qt/qt/include/qstring.h:227: redefinition of `int cl'
/qt/qt/include/qstring.h:220: `int cl' previously defined here
/qt/qt/include/qstring.h:227: `c' was not declared in this scope
/qt/qt/include/qstring.h:231: parse error before `}' token
/qt/qt/include/qstring.h: In copy constructor `QChar::QChar(const QChar&)':
/qt/qt/include/qstring.h:234: `class QChar' has no member named `rw'
/qt/qt/include/qstring.h:234: `class QChar' has no member named `cl'
/qt/qt/include/qstring.h: In function `int operator==(char, QChar)':
/qt/qt/include/qstring.h:271: `class QChar' has no member named `cl'
/qt/qt/include/qstring.h:271: `class QChar' has no member named `rw'
/qt/qt/include/qstring.h: In function `int operator==(QChar, char)':
/qt/qt/include/qstring.h:276: `class QChar' has no member named `cl'
/qt/qt/include/qstring.h:276: `class QChar' has no member named `rw'
/qt/qt/include/qstring.h: In function `int operator==(QChar, QChar)':
/qt/qt/include/qstring.h:281: `class QChar' has no member named `cl'
/qt/qt/include/qstring.h:282: `class QChar' has no member named `cl'
/qt/qt/include/qstring.h:282: `class QChar' has no member named `rw'
/qt/qt/include/qstring.h:282: `class QChar' has no member named `rw'
/qt/qt/include/qstring.h: In function `int operator!=(QChar, QChar)':
/qt/qt/include/qstring.h:287: `class QChar' has no member named `cl'
/qt/qt/include/qstring.h:288: `class QChar' has no member named `cl'
/qt/qt/include/qstring.h:288: `class QChar' has no member named `rw'
/qt/qt/include/qstring.h:288: `class QChar' has no member named `rw'
/qt/qt/include/qstring.h: In function `int operator!=(char, QChar)':
/qt/qt/include/qstring.h:293: `class QChar' has no member named `cl'
/qt/qt/include/qstring.h:293: `class QChar' has no member named `rw'
/qt/qt/include/qstring.h: In function `int operator!=(QChar, char)':
/qt/qt/include/qstring.h:298: `class QChar' has no member named `cl'
/qt/qt/include/qstring.h:298: `class QChar' has no member named `rw'
/qt/qt/include/qstring.h: In function `int operator<=(QChar, char)':
/qt/qt/include/qstring.h:303: `class QChar' has no member named `cl'
/qt/qt/include/qstring.h:303: `class QChar' has no member named `rw'
/qt/qt/include/qstring.h: In function `int operator<=(char, QChar)':
/qt/qt/include/qstring.h:308: `class QChar' has no member named `cl'
/qt/qt/include/qstring.h:308: `class QChar' has no member named `rw'
/qt/qt/include/qstring.h: In function `int operator<=(QChar, QChar)':
/qt/qt/include/qstring.h:313: `class QChar' has no member named `rw'
/qt/qt/include/qstring.h:314: `class QChar' has no member named `rw'
/qt/qt/include/qstring.h:315: `class QChar' has no member named `rw'
/qt/qt/include/qstring.h:316: `class QChar' has no member named `rw'
/qt/qt/include/qstring.h:317: `class QChar' has no member named `cl'
/qt/qt/include/qstring.h:317: `class QChar' has no member named `cl'
In file included from /qt/qt/include/qwindowdefs.h:44,
from /qt/qt/include/qwidget.h:42,
from /qt/qt/include/qbutton.h:42,
from /qt/qt/include/qpushbutton.h:42,
from hello.cpp:2:
/qt/qt/include/qstring.h: At global scope:
/qt/qt/include/qstring.h:573: `uchar' was not declared in this scope
/qt/qt/include/qstring.h:573: parse error before `)' token
/qt/qt/include/qstring.h:573: `QCharRef QCharRef::operator=(...)' must take
exactly one argument
/qt/qt/include/qstring.h:607: parse error before `)' token
In file included from /qt/qt/include/qwindowdefs.h:44,
from /qt/qt/include/qwidget.h:42,
from /qt/qt/include/qbutton.h:42,
from /qt/qt/include/qpushbutton.h:42,
from hello.cpp:2:
/qt/qt/include/qstring.h: In member function `QCharRef
QCharRef::operator=(...)':
/qt/qt/include/qstring.h:573: `c' undeclared (first use this function)
In file included from /qt/qt/include/qwindowdefs.h:44,
from /qt/qt/include/qwidget.h:42,
from /qt/qt/include/qbutton.h:42,
from /qt/qt/include/qpushbutton.h:42,
from hello.cpp:2:
/qt/qt/include/qstring.h: At global scope:
/qt/qt/include/qstring.h:608: ISO C++ forbids defining types within return type
/qt/qt/include/qstring.h:608: syntax error before `(' token
/qt/qt/include/qstring.h:612: semicolon missing after declaration of `class
QCharRef'
/qt/qt/include/qstring.h: In member function `int QString::at(QString*,
unsigned int)':
/qt/qt/include/qstring.h:612: cannot convert `QCharRef' to `int' in return
/qt/qt/include/qstring.h: In member function `QCharRef
QString::operator[](int)':
/qt/qt/include/qstring.h:613: conversion from `QChar' to non-scalar type `
QCharRef' requested
In file included from /qt/qt/include/qobject.h:45,
from /qt/qt/include/qwidget.h:43,
from /qt/qt/include/qbutton.h:42,
from /qt/qt/include/qpushbutton.h:42,
from hello.cpp:2:
/qt/qt/include/qevent.h: At global scope:
/qt/qt/include/qevent.h:224: 'uchar' is used as a type, but is not defined as a
type.
/qt/qt/include/qevent.h: In constructor `QKeyEvent::QKeyEvent(QEvent::Type,
int, int, int, const QString&, bool, short unsigned int)':
/qt/qt/include/qevent.h:209: parse error before `;' token
/qt/qt/include/qevent.h: In member function `QKeyEvent::QKeyEvent(QEvent::Type,
int, int, int, const QString&, bool, short unsigned int)':
/qt/qt/include/qevent.h:208: warning: unused parameter `int ascii'
/qt/qt/include/qevent.h: In member function `int QKeyEvent::ascii() const':
/qt/qt/include/qevent.h:211: `a' undeclared (first use this function)
In file included from /qt/qt/include/qiconset.h:42,
from /qt/qt/include/qpushbutton.h:43,
from hello.cpp:2:
/qt/qt/include/qpixmap.h: At global scope:
/qt/qt/include/qpixmap.h:118: parse error before `*' token
/qt/qt/include/qpixmap.h:121: parse error before `*' token
/qt/qt/include/qpixmap.h:123: `bool QPixmap::loadFromData(...)' and `bool
QPixmap::loadFromData(...)' cannot be overloaded
/qt/qt/include/qpixmap.h:172: parse error before `*' token
hello.cpp: In constructor `MyWidget::MyWidget(QWidget*, const char*)':
hello.cpp:38: `qApp' undeclared (first use this function)
hello.cpp: In function `int main(int, char**)':
hello.cpp:49: variable `QApplication a' has initializer but incomplete type
/qt/qt/include/qvaluelist.h: At top level:
/qt/qt/include/qstring.h:171: warning: `bool networkOrdered()' defined but not
used
{standard input}: Assembler messages:
{standard input}:13: Error: symbol `cl' is already defined
make: *** [hello.o] Error 1

××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××


下面是代码!!!

××××××××××××××××××××××××××××××
××××××××××××××××××××××××××××××
#include <qapplication.h>
#include <qpushbutton.h>
#include <qslider.h>
#include <qlcdnumber.h>
#include <qfont.h>
#include <qvbox.h>
#include <qgrid.h>

class LCDRange : public QVBox
{
public:
LCDRange( QWidget *parent=0, const char *name=0 );
};

LCDRange::LCDRange( QWidget *parent, const char *name )
: QVBox( parent, name )
{
QLCDNumber *lcd = new QLCDNumber( 2, this, "lcd" );
QSlider * slider = new QSlider( Horizontal, this, "slider" );
slider->setRange( 0, 99 );
slider->setValue( 0 );
connect( slider, SIGNAL(valueChanged(int)), lcd, SLOT(display(int)) );
}

class MyWidget : public QVBox
{
public:
MyWidget( QWidget *parent=0, const char *name=0 );
};


MyWidget::MyWidget( QWidget *parent, const char *name )
: QVBox( parent, name )
{
QPushButton *quit = new QPushButton( "Quit", this, "quit" );
quit->setFont( QFont( "Times", 18, QFont::Bold ) );

connect( quit, SIGNAL(clicked()), qApp, SLOT(quit()) );

QGrid *grid = new QGrid( 4, this );

for( int r = 0 ; r < 4 ; r++ )
for( int c = 0 ; c < 4 ; c++ )
(void)new LCDRange( grid );
}

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

MyWidget w;
a.setMainWidget( &w );
w.show();
return a.exec();
}


××××××××××××××××××××××××××××××
民国陪都
可愛的小學生
可愛的小學生
 
文章: 12
註冊時間: 週二 3月 29, 2005 8:28 am

文章民国陪都 » 週二 3月 29, 2005 7:16 pm

我用的是TMAKE--1.7
民国陪都
可愛的小學生
可愛的小學生
 
文章: 12
註冊時間: 週二 3月 29, 2005 8:28 am

文章民国陪都 » 週三 3月 30, 2005 8:10 am

我晕哦!!!难道就没好心人帮我嘛???郁闷!!!! :-(
民国陪都
可愛的小學生
可愛的小學生
 
文章: 12
註冊時間: 週二 3月 29, 2005 8:28 am

文章訪客 » 週三 3月 30, 2005 1:04 pm

看起來你的環境設定有問題!
建議你先用RedHat…等準系統
它把所有環境變數都設好
你只要執行Qt designer
內有help也有menual&&範例
試試吧!
訪客
 

文章民国陪都 » 週三 3月 30, 2005 1:55 pm

谢谢了,是我自己搞错了!!!!
民国陪都
可愛的小學生
可愛的小學生
 
文章: 12
註冊時間: 週二 3月 29, 2005 8:28 am


回到 KDE/Qt 程式設計

誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 1 位訪客

cron