LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-30-2009, 01:12 AM   #1
grsandeep85
LQ Newbie
 
Registered: Sep 2008
Posts: 10

Rep: Reputation: 0
Qt Compilation Errors


Hi all,
I am new to Qt i have developed sample Qt program using some pushbuttons and line edit when i try to compile this program i get the following errors

Drass:/home/soumya/samsung/qtsample # /usr/lib/qt3/bin/qmake -project
Drass:/home/soumya/samsung/qtsample # /usr/lib/qt3/bin/qmake
Drass:/home/soumya/samsung/qtsample # ls
Makefile form1.ui form1.ui.h main.cpp qtsample.pro
Drass:/home/soumya/samsung/qtsample # make
/usr/lib/qt3/bin/uic form1.ui -o form1.h
g++ -c -pipe -O2 -march=i586 -mtune=i686 -fmessage-length=0 -Wall -D_FORTIFY_SOURCE=2 -g -fno-strict-aliasing -Wall -W -O2 -march=i586 -mtune=i686 -fmessage-length=0 -Wall -D_FORTIFY_SOURCE=2 -g -fno-strict-aliasing -DQT_NO_DEBUG -DQT_SHARED -DQT_THREAD_SUPPORT -I/usr/lib/qt3/mkspecs/default -I. -I. -I/usr/include -I/usr/lib/qt3/include -o main.o main.cpp
/usr/lib/qt3/bin/uic form1.ui -i form1.h -o form1.cpp
g++ -c -pipe -O2 -march=i586 -mtune=i686 -fmessage-length=0 -Wall -D_FORTIFY_SOURCE=2 -g -fno-strict-aliasing -Wall -W -O2 -march=i586 -mtune=i686 -fmessage-length=0 -Wall -D_FORTIFY_SOURCE=2 -g -fno-strict-aliasing -DQT_NO_DEBUG -DQT_SHARED -DQT_THREAD_SUPPORT -I/usr/lib/qt3/mkspecs/default -I. -I. -I/usr/include -I/usr/lib/qt3/include -o form1.o form1.cpp
form1.ui.h: In member function ‘void form1::init()’:
form1.ui.h:23: error: ‘xLineEdit’ was not declared in this scope
form1.ui.h:28: error: ‘yLineEdit’ was not declared in this scope
form1.ui.h:33: error: ‘zLineEdit’ was not declared in this scope
form1.ui.h: In member function ‘virtual void form1::convert1()’:
form1.ui.h:42: error: ‘xLineEdit’ was not declared in this scope
form1.ui.h:44: error: ‘X’ is not a member of ‘QString’
form1.ui.h:44: error: ‘decimals’ was not declared in this scope
form1.ui.h:43: warning: unused variable ‘scaledInput’
form1.ui.h: In member function ‘virtual void form1::convert2()’:
form1.ui.h:48: error: ‘yLineEdit’ was not declared in this scope
form1.ui.h:50: error: ‘Y’ is not a member of ‘QString’
form1.ui.h:50: error: ‘decimals’ was not declared in this scope
form1.ui.h:49: warning: unused variable ‘scaledInput’
form1.ui.h: In member function ‘virtual void form1::convert3()’:
form1.ui.h:54: error: ‘zLineEdit’ was not declared in this scope
form1.ui.h:56: error: ‘Z’ is not a member of ‘QString’
form1.ui.h:56: error: ‘decimals’ was not declared in this scope
form1.ui.h:55: warning: unused variable ‘scaledInput’
make: *** [form1.o] Error 1

here is the full code which includes form1.ui form1.ui.h main.cpp Makefile qtsample.pro

************form1.ui.h********
#include <qvalidator.h>
#include <qstring.h>
#include <qdialog.h>
#include <qlineedit.h>
#include <qfont.h>
#include <qfontinfo.h>

void form1::init()
{
xLineEdit->setValidator( new QDoubleValidator( xLineEdit ) );
xLineEdit->setText( "10" );
convert1();
xLineEdit->selectAll();

yLineEdit->setValidator( new QDoubleValidator( yLineEdit ) );
yLineEdit->setText( "10" );
convert2();
yLineEdit->selectAll();

zLineEdit->setValidator( new QDoubleValidator( zLineEdit ) );
zLineEdit->setText( "10" );
convert3();
zLineEdit->selectAll();
}

void form1::convert1()
{
// Retrieve the input
double input1 = xLineEdit->text().toDouble();
double scaledInput = input1;
xLineEdit->setText( QString::X( input1, 'f', decimals );
}
void form1::convert2()
{
double input2 = yLineEdit->text().toDouble();
double scaledInput = input2;
yLineEdit->setText( QString::Y( input2, 'f', decimals );
}
void form1::convert3()
{
double input3 = zLineEdit->text().toDouble();
double scaledInput = input3;
zLineEdit->setText( QString::Z( input3, 'f', decimals );
}
**********END**************

*********main.cpp************
#include <qapplication.h>
#include "form1.h"

int main( int argc, char ** argv )
{
QApplication a( argc, argv );
form1 w;
w.show();
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
return a.exec();
}
************end*****************
**********qtsample.pro************

######################################################################
# Automatically generated by qmake (2.01a) Thu Apr 30 10:47:25 2009
######################################################################

TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .

# Input
HEADERS += form1.ui.h
FORMS += form1.ui
SOURCES += main.cpp
************end**************

Please anyone can help me asap.
 
Old 04-30-2009, 01:15 AM   #2
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
You haven't actually declared some of your variables, like xLineEdit. All variables need to be declared with a type, e.g.

int x;
 
Old 04-30-2009, 02:49 AM   #3
grsandeep85
LQ Newbie
 
Registered: Sep 2008
Posts: 10

Original Poster
Rep: Reputation: 0
Hi Nylex,

Thanks for your reply but it didnt work i got few more errors,


form1.ui.h: In member function ‘void form1::init()’:
form1.ui.h:25: error: base operand of ‘->’ is not a pointer
form1.ui.h:25: error: invalid conversion from ‘int’ to ‘QObject*’
form1.ui.h:25: error: initializing argument 1 of ‘QDoubleValidator::QDoubleValidator(QObject*, const char*)’
form1.ui.h:26: error: base operand of ‘->’ is not a pointer
form1.ui.h:28: error: base operand of ‘->’ is not a pointer
form1.ui.h:30: error: base operand of ‘->’ is not a pointer
form1.ui.h:30: error: invalid conversion from ‘int’ to ‘QObject*’
form1.ui.h:30: error: initializing argument 1 of ‘QDoubleValidator::QDoubleValidator(QObject*, const char*)’
form1.ui.h:31: error: base operand of ‘->’ is not a pointer
form1.ui.h:33: error: base operand of ‘->’ is not a pointer
form1.ui.h:35: error: base operand of ‘->’ is not a pointer
form1.ui.h:35: error: invalid conversion from ‘int’ to ‘QObject*’
form1.ui.h:35: error: initializing argument 1 of ‘QDoubleValidator::QDoubleValidator(QObject*, const char*)’
form1.ui.h:36: error: base operand of ‘->’ is not a pointer
form1.ui.h:38: error: base operand of ‘->’ is not a pointer
form1.ui.h: In member function ‘virtual void form1::convert1()’:
form1.ui.h:45: error: ‘xLineEdit’ was not declared in this scope
form1.ui.h:47: error: ‘X’ is not a member of ‘QString’
form1.ui.h: In member function ‘virtual void form1::convert2()’:
form1.ui.h:52: error: ‘yLineEdit’ was not declared in this scope
form1.ui.h:54: error: ‘Y’ is not a member of ‘QString’
form1.ui.h: In member function ‘virtual void form1::convert3()’:
form1.ui.h:59: error: ‘zLineEdit’ was not declared in this scope
form1.ui.h:61: error: ‘Z’ is not a member of ‘QString’
make: *** [form1.o] Error 1

xLineEdit is not a variable its a function is it, so no need to initialise.
 
Old 05-10-2009, 03:07 AM   #4
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Are the functions like xLineEdit declared anywhere? Also, in your main.cpp, you have

#include "form1.h"

Should that be "form1.ui.h"? Can you indicate in which lines those errors occur please? I know the line numbers are on there, but there aren't any line numbers on the forums, unfortunately.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Kernel 2.6.28 compilation errors Nikosis Linux - Kernel 15 02-25-2009 10:00 AM
compilation errors in g++ manikan Linux - Software 1 02-03-2006 05:31 AM
GCC Compilation Errors The_Dish Programming 7 10-08-2004 04:33 PM
C++ compilation errors ??? glevine Programming 1 07-16-2004 03:15 PM
Compilation Errors ! vipinsharma Programming 0 06-01-2004 02:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration