Qt [LÖST]

Här diskuteras programmering och utveckling
Användarvisningsbild
madbear
Inlägg: 209
Blev medlem: 09 jan 2007, 13:49
OS: PCLinuxOS
Ort: Karlstad

Qt [LÖST]

Inlägg 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);
}
Senast redigerad av 1 DrMegahertz, redigerad totalt 30 gånger.
Användarvisningsbild
gasol
Inlägg: 405
Blev medlem: 27 jul 2007, 14:57
Kontakt:

SV: Qt

Inlägg 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?
The Black Mountain Scorpion Hoedown Bluegrass Experience Gang
From Left to Right: Wizard on Bicycle, Wizard on Bicycle, Wizard on Bicycle, Wizard on Bicycle, Wizard on Bicycle.
Användarvisningsbild
madbear
Inlägg: 209
Blev medlem: 09 jan 2007, 13:49
OS: PCLinuxOS
Ort: Karlstad

SV: Qt

Inlägg av madbear »

qtopiamake sen make :S
la till lite i filen det funkade innan jag pillat
Användarvisningsbild
gasol
Inlägg: 405
Blev medlem: 27 jul 2007, 14:57
Kontakt:

SV: Qt

Inlägg 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?)
The Black Mountain Scorpion Hoedown Bluegrass Experience Gang
From Left to Right: Wizard on Bicycle, Wizard on Bicycle, Wizard on Bicycle, Wizard on Bicycle, Wizard on Bicycle.
Användarvisningsbild
madbear
Inlägg: 209
Blev medlem: 09 jan 2007, 13:49
OS: PCLinuxOS
Ort: Karlstad

SV: Qt

Inlägg av madbear »

tack!!!
nu funkade det :)
Skriv svar

Återgå till "Programmering och webbdesign"