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

Author Topic: Problem with setReportVariable and img source  (Read 123 times)

salvo

  • Newbie
  • *
  • Posts: 3
    • View Profile
Problem with setReportVariable and img source
« on: June 04, 2020, 11:04:24 AM »
Hi,

I'm having problem when trying to assign an image using setReportVariable.
This is the code:
Code: [Select]
report->dataManager()->setReportVariable("Logo", "<img source = "+ FolderPath +"/Resource/STAR2K_FONDI_CHIARI.jpg width=826 height= 237>");
Now when I run it in local the FolderPath is:  C:\Progetti\QT_Project\App and everything works fine.
When I try to install my application on another pc the FolderPath became: C:/Program Files (x86)/MyApp And suddendly it doesnt't return the image. I'm sure the image is available in the correct path in both version. It looks like there is something with blank spaces but I don't know how can I handle that.

I also tried to replace spaces with '%20' as following:
"<img source = C:/Program%20Files%20(x86)/MyApp/Resource/STAR2K_FONDI_CHIARI.jpg width=826 height= 237>"
Is this uncorrect? I'm using a text item and I checked allowHTML and allowHTMLInFields.


What am I doing wrong?

Thanks for your help!
« Last Edit: June 04, 2020, 01:14:10 PM by salvo »

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 847
    • View Profile
Re: Problem with setReportVariable and img source
« Reply #1 on: June 14, 2020, 03:49:55 PM »
Hi!
You can put an image into a resource file.
Then use the resource path to init an image.

salvo

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Problem with setReportVariable and img source
« Reply #2 on: June 16, 2020, 01:40:41 PM »
Hi Alex!

unfortunately I cannot do this trick. Some images are created at runtime taking a screenshot of the window and I save them into a folder pointed by FolderPath that contains the full path to the folder. So I have to use the full path to get this images.

Is there a way to do that without having the error above?

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 847
    • View Profile
Re: Problem with setReportVariable and img source
« Reply #3 on: June 20, 2020, 10:16:36 AM »
Why are you using TextItem to show an image?
Try to add quotes
report->dataManager()->setReportVariable("Logo", "<img source =\" "+ FolderPath +"/Resource/STAR2K_FONDI_CHIARI.jpg \" width=826 height= 237>");
« Last Edit: June 20, 2020, 12:10:20 PM by Arin Alex »

salvo

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Problem with setReportVariable and img source
« Reply #4 on: June 24, 2020, 10:50:45 AM »
That's a good question  ;D
Unfortunately I didn't write this code, I don't know why TextItem has been choosen for this purpose...
Anyway, adding quotes still doesn't work, maybe can you point me to the correct approach I should use in this case?

Thanks again for the support! :D

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 847
    • View Profile
Re: Problem with setReportVariable and img source
« Reply #5 on: June 25, 2020, 05:21:51 PM »
LimeReport has ImageItem for this purpose.
If you use ImageItem you can show a variable that contains an image
or resourcePath property to set up the path to an image.