Sida 1 av 1

Qt [LÖST]

Postat: 27 sep 2007, 18:33
av madbear
Försöker bygga ett program till greenphone, det var med i linux format, har tillochmed klistrat och klippt från en fil men får fel när jag ska kompilera :
--- Jag är nybörjare :S , löste några fel genom att söka igenom koden men kommer inte längre nu.

Kod: Markera allt

example.cpp: In member function 'void Example::conVert()':
example.cpp:59: error: 'Qstring' was not declared in this scope
example.cpp:59: error: expected `;' before 'amount_str'
example.cpp:60: error: 'amount_str' was not declared in this scope
example.cpp:64: error: expected primary-expression before '==' token
example.cpp:64: error: expected `;' before ')' token
här är programet.

Kod: Markera allt

#include <qstring.h>
#include <qlineedit.h>
#include <qlcdnumber.h>
#include <qcombobox.h>
#include "example.h"
#include <qpushbutton.h>

ExampleBase::ExampleBase( QWidget *parent, Qt::WFlags f )
    : QWidget( parent, f )
{
    setupUi( this );
}

ExampleBase::~ExampleBase()
{
}

/* 
 *  Constructs a Example which is a child of 'parent', with the 
 *  name 'name' and widget flags set to 'f' 
 */
Example::Example( QWidget *parent, Qt::WFlags f )
    : ExampleBase( parent, f )
{
    connect(quit, SIGNAL(clicked()), this, SLOT(goodBye()));
    connect (pushButton, SIGNAL(clicked()), this, SLOT(conVert()));
}

/*  
 *  Destroys the object and frees any allocated resources
 */
Example::~Example()
{
    // no need to delete child widgets, Qt does it all for us
}

/*
 *  A simple slot... not very interesting.
 */
void Example::goodBye()
{
    close();
}

void Example::conVert()
{
Qstring amount_str = lineEdit->text();
float amount = amount_str.toFloat();
switch (comboBox->currentIndex())
{
	case 0:
	if (comboBox_2->currentIndex()) == 1)
	 amount = amount * 0.3937;
	break;
}
lcdNumber->display(amount);
}

SV: Qt

Postat: 27 sep 2007, 19:50
av gasol
Vad använder du för kommandon för att kompilera?
Använder du dig av moc?
Dom fel som du presenterar är det alla fel som gcc ger dig?

SV: Qt

Postat: 27 sep 2007, 20:09
av madbear
qtopiamake sen make :S
la till lite i filen det funkade innan jag pillat

SV: Qt

Postat: 27 sep 2007, 20:21
av gasol
Qstring amount_str = lineEdit->text();
ska vara
QString amount_str = lineEdit->text(); (Stort S i String)



if (comboBox_2->currentIndex()) == 1)
ska  vara
if (comboBox_2->currentIndex() == 1)  (Ser du att jag tog bort en parantes där?)

SV: Qt

Postat: 27 sep 2007, 20:31
av madbear
tack!!!
nu funkade det :)