Welcome, Guest. Please login or register.
Did you miss your activation email?

Author Topic: How to check if model loaded before to dataManager?  (Read 5493 times)

Mucip

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
How to check if model loaded before to dataManager?
« on: February 27, 2020, 06:08:19 pm »
Hi,
I have definitons in header file like below;

QSqlQueryModel *raporModel;
LimeReport::ReportEngine *mRapor;


And in mainwindow.cpp

mRapor = new LimeReport::ReportEngine(this);
raporModel = new QSqlQueryModel(this);


And when I press the showReport button;

raporModel->setQuery("SELECT * FROM tartim WHERE belge_no = '" + belge_no + "' ;");

mRapor->dataManager()->addModel("Tartim", raporModel, true);
mRapor->designReport();


Well, the problem is when I push the showReport button second time it raise error because I wanted to load same model second time. :(

How can I check if the same model name loaded before? Or can I clean the model from dataManeger when I close preview or print the report? Maybe this is better for memoryleak?

P.S: I can not drag the model fields on the report page with mouse! Is it because of the readonly Model?...

Regards,
Mucip:)



« Last Edit: February 27, 2020, 06:12:34 pm by Mucip »

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1005
    • View Profile
Re: How to check if model loaded before to dataManager?
« Reply #1 on: February 27, 2020, 08:12:32 pm »
Hi!
The mistake is here:

mRapor->dataManager()->addModel("Tartim", raporModel, true);

When the third parameter is true it says to limereport that it must get ownership to model
When you try to put the model to datamanager in the second time
it throws the exception (this is my fault i had to prevent this) because datamanager deleted the model because the model is owned him.
In your case, you needn't transfer ownership to limereport you can just set the third parameter to false;

Mucip

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: How to check if model loaded before to dataManager?
« Reply #2 on: February 27, 2020, 10:03:14 pm »
Hi,
Thanks. I use "false" parameter than.

But I have one big problem either. I can not drag and drop model field from dataBrowser in Report designer unfortunately. :(

Why?

But I can put text object in dhe band and set it to "$D{tartim.plaka}". Interesting?...

Regards,
Mucip:)
 
« Last Edit: February 27, 2020, 10:06:01 pm by Mucip »

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1005
    • View Profile
Re: How to check if model loaded before to dataManager?
« Reply #3 on: February 28, 2020, 11:42:09 am »
It's very strange. Could you make a video?

Mucip

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: How to check if model loaded before to dataManager?
« Reply #4 on: February 28, 2020, 11:56:49 am »
Hi,
Please watch ths video...

https://autode.sk/2PwwYsh

Regards,
Mucip:)

Mucip

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: How to check if model loaded before to dataManager?
« Reply #5 on: February 28, 2020, 12:07:25 pm »
Hi,
I guess the error comes from DefaultConnection somehow?! Because only differenc is this with the LimeReportDemo... :(


Regards,
Mucip:)

Mucip

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: How to check if model loaded before to dataManager?
« Reply #6 on: February 28, 2020, 03:47:35 pm »
Hi,
Could you watch the video Mr. Arin?

Any feedback?

Regards,
Mucip:)

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1005
    • View Profile
Re: How to check if model loaded before to dataManager?
« Reply #7 on: February 28, 2020, 04:41:29 pm »
I have watched the video.
I am very surprised.
I try to reproduce the same behavior, but no results.
At your video, i sow that databrowser has no drag and drop behavior.
What OS do you use?
« Last Edit: February 28, 2020, 04:46:17 pm by Arin Alex »

Mucip

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: How to check if model loaded before to dataManager?
« Reply #8 on: February 28, 2020, 04:44:52 pm »
Hi,
I connected to SQLite db.

If you really want to see the situation, you may connect me via TemViewer or something else.

If yes, I will send you ID?

Regards,
Mucip:)

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1005
    • View Profile
Re: How to check if model loaded before to dataManager?
« Reply #9 on: February 28, 2020, 04:48:19 pm »
Say me pleases in my demo drag and drop works as expected?

Mucip

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: How to check if model loaded before to dataManager?
« Reply #10 on: February 28, 2020, 04:49:58 pm »
Hi,
Sorry. I didn't understand...

Regards,
Mucip:)

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1005
    • View Profile
Re: How to check if model loaded before to dataManager?
« Reply #11 on: February 28, 2020, 04:54:47 pm »
Ok, send me TeamViewerID :) I have a little time :)

Mucip

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: How to check if model loaded before to dataManager?
« Reply #12 on: February 28, 2020, 05:18:10 pm »
Hi,
I sent you by email...

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1005
    • View Profile
Re: How to check if model loaded before to dataManager?
« Reply #13 on: February 28, 2020, 05:23:32 pm »
Nop :( Wrong TeamViewer says that password is wrong

Mucip

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Re: How to check if model loaded before to dataManager?
« Reply #14 on: February 28, 2020, 05:27:47 pm »
Hi,
I sent you second...

Please check your email again.