QFile - Problem with generated setter
-
Thank you! :-)
-
Ok... that was too early. I don't even know why the setter is not working. Can you please give me an example of a working setter for my example? I have checked the return values but I don't come to a resolution. It is not working :-(
Thx in advance!
buzzzzz -
Ok... that was too early. I don't even know why the setter is not working. Can you please give me an example of a working setter for my example? I have checked the return values but I don't come to a resolution. It is not working :-(
Thx in advance!
buzzzzz@buzz_lightzyear
QString
,QDate
andQImage
are notQObject
s and so can be copied and a setter can be written.QFile
however inheritsQObject
. That means it cannot be copied. You won't be able to do agpxFile = newGpxFile
like for the others. Even though the IDE may let you try to write a setter for it you won't get it to work.You might perhaps have a pointer to a
QObject
-derived class (e.g.QFile *
) as a member variable with a setter, but that's another matter.Even if it worked, what would you want to set/copy a
QFile
for? -
Ok thanks for your answer. The idea behind that is a simple bike-tour logger with a sqlite database in background. After a tour I want to enter the tourdata (eg. odometer...) to get a statistic over my tours over the year. And therefore I want also to upload the GPS generated tour as blob into the database. For that reason I thought a QFile is the best class for that because I don't want to edit the gpx file. But it seems to be hard. Do you have an example for another class?
Thx and goobye,
buzzzzz -
Ok thanks for your answer. The idea behind that is a simple bike-tour logger with a sqlite database in background. After a tour I want to enter the tourdata (eg. odometer...) to get a statistic over my tours over the year. And therefore I want also to upload the GPS generated tour as blob into the database. For that reason I thought a QFile is the best class for that because I don't want to edit the gpx file. But it seems to be hard. Do you have an example for another class?
Thx and goobye,
buzzzzz@buzz_lightzyear
Since you're talking about sqlite, the only information you need is the filepath of the database.
And then, just open and update that database when you needed to. -
@buzz_lightzyear
Since you're talking about sqlite, the only information you need is the filepath of the database.
And then, just open and update that database when you needed to.@mpergand said in QFile - Problem with generated setter:
@buzz_lightzyear
Since you're talking about sqlite, the only information you need is the filepath of the database.
And then, just open and update that database when you needed to.thx but I think this is not this what I need now. The database connection is already established.
-
@mpergand said in QFile - Problem with generated setter:
@buzz_lightzyear
Since you're talking about sqlite, the only information you need is the filepath of the database.
And then, just open and update that database when you needed to.thx but I think this is not this what I need now. The database connection is already established.
@buzz_lightzyear said in QFile - Problem with generated setter:
The database connection is already established.
So why do you need a QFile object for it then? If you open a sqlite database with Qt you don't need a QFile object at all.
-
Ok thanks for your answer. The idea behind that is a simple bike-tour logger with a sqlite database in background. After a tour I want to enter the tourdata (eg. odometer...) to get a statistic over my tours over the year. And therefore I want also to upload the GPS generated tour as blob into the database. For that reason I thought a QFile is the best class for that because I don't want to edit the gpx file. But it seems to be hard. Do you have an example for another class?
Thx and goobye,
buzzzzz@buzz_lightzyear said in QFile - Problem with generated setter:
I want also to upload the GPS generated tour as blob into the database. For that reason I thought a QFile is the best class for that
-
You can use a
QFile
for this if you wish, you just can't copy/assign via the setter you were trying. As I said earlier, aQFile *
could be used in the pattern you are choosing. -
Or you could pass e.g. the file path around and use
QFile
when you need to read in the contents to send as a blob to the database.
-
-
So why do you need a QFile object for it then? If you open a sqlite database with Qt you don't need a QFile object at all.
I need the QFile object for the gpx-file, not for the SQlite database. For that I have the QSqlDatabase class.
-
@buzz_lightzyear said in QFile - Problem with generated setter:
I want also to upload the GPS generated tour as blob into the database. For that reason I thought a QFile is the best class for that
-
You can use a
QFile
for this if you wish, you just can't copy/assign via the setter you were trying. As I said earlier, aQFile *
could be used in the pattern you are choosing. -
Or you could pass e.g. the file path around and use
QFile
when you need to read in the contents to send as a blob to the database.
@JonB said in QFile - Problem with generated setter:
@buzz_lightzyear said in QFile - Problem with generated setter:
I want also to upload the GPS generated tour as blob into the database. For that reason I thought a QFile is the best class for that
-
You can use a
QFile
for this if you wish, you just can't copy/assign via the setter you were trying. As I said earlier, aQFile *
could be used in the pattern you are choosing. -
Or you could pass e.g. the file path around and use
QFile
when you need to read in the contents to send as a blob to the database.
ok thanks... then I will try it this way.
-
-
So why do you need a QFile object for it then? If you open a sqlite database with Qt you don't need a QFile object at all.
I need the QFile object for the gpx-file, not for the SQlite database. For that I have the QSqlDatabase class.
@buzz_lightzyear said in QFile - Problem with generated setter:
I need the QFile object for the gpx-file
No you don't as @JonB already told you (several times iirc)