PDA

View Full Version : data base in qt



Fafa
13th June 2011, 18:08
hi.
i wanna make an application that with this you can reserve ticket for your travel , in fact
designing system of one airline and when i want to create database(some 2d matrix that save number of seat in flights ,it errors.
the number of flight set in different place and the is changing
this is my code:

QString** matrix = new QString*[numberofFlights];
for (int i = 0; i < numberofFlight; i++)
{
matrix[i] = new QString[numberofSeats];
}


what class in qt should i use.

can someone help me ,i 'm in hurry
thanks

deyili
14th June 2011, 03:02
QGenericMatrix is an option, but the number of row and column is unchangable.

and for you code:
QString** matrix = new QString*[numberofFlights];
for (int i = 0; i < numberofFlight; i++) // is this misspelled?

ChrisW67
15th June 2011, 00:52
You have built yourself a memory management nightmare there. How about:


int numberofFlights = 5;
int numberofSeats = 20;

QVector<QVector<QString> > flightMatrix;
flightMatrix.resize(numberofFlights);
foreach(QVector<QString> flight, flightMatrix)
flight.resize(numberofSeats);