LimeReport Forum
General Category | Основное => Discussion | Обсуждение => Topic started by: maurosanjo on December 01, 2016, 11:34:30 pm
-
Hi there,
In the way LimeReport was designed the image can be static and also associated with a DataSoure.Field. But imagine we have a custom report in which we need to programatically change the company logo.
Is there any way?
If not, would be interesting if we could treat the image as a text field and set a Report Variable to it?
Congrats on the Report Designer tool, the best look'n feel and usability I found among Qt report solutions :D
Regards
-
Hi !
Thank you for your kind words to the LimeReport :)
You can use TextItem for printing images from application resources. To do this you should allowHtml in TextItem and specify the path to the resource like this <img source=":/report//images/pin"/>
-
Hello,
Thanks. I tried that, its not as clean as what you did on your categories example. Using Image we can take advantage of scale, keepAspectRation, etc.
Something is strange, if I put a Image on Data Band and set Resource and Field on it, on the slot & signal mechanism I can set a QImage to data and it works fine. But if I put the Image on the group header, of footer, no matter if I put it on columnData or not, it gets fetched (more than once by the way) on the callback function but setting QImage to data (QVariant) does not work. Is it a bug or a limitation?
Regards
-
Hi !
Thanks. I tried that, its not as clean as what you did on your categories example. Using Image we can take advantage of scale, keepAspectRation, etc.
I have added resourcePath property to ImageItem. From now you can use something like this ":report/images/pin" in this property
Something is strange, if I put a Image on Data Band and set Resource and Field on it, on the slot & signal mechanism I can set a QImage to data and it works fine. But if I put the Image on the group header, of footer, no matter if I put it on columnData or not, it gets fetched (more than once by the way) on the callback function but setting QImage to data (QVariant) does not work. Is it a bug or a limitation?
It's very strange :) I have tried to repeat that case but I didn't get same result.
I have used next callback slot :
void MainWindow::slotOneSlotDS(LimeReport::CallbackInfo info, QVariant &data)
{
QStringList columns;
columns << "Name" << "Value" << "Image";
switch (info.dataType) {
case LimeReport::CallbackInfo::RowCount:
data = 4;
break;
case LimeReport::CallbackInfo::ColumnCount:
data = columns.size();
break;
case LimeReport::CallbackInfo::IsEmpty:
data = false;
break;
case LimeReport::CallbackInfo::ColumnHeaderData: {
data = columns.at(info.index);
break;
}
case LimeReport::CallbackInfo::ColumnData:
if (info.columnName == "Image")
data = QImage(":/report//images/logo32");
else {
data = info.columnName+" "+QString::number(info.index);
}
break;
default: break;
}
}
and attached report
and I got the result that you can see on the attached image
[вложение удалено администратором]
-
Oh man, so sorry, it was a problem on my resource images. Indeed it is working :P Thanks
-
hi,could you give an example for this! thank you very much
-
Hi!
What kind of example do you want? If you want to know how to use an image from the application resources here is an example:
1. Allow HTML in TextItem
2. Put this sample string into the item content <img source=":/report//images/pin" width="100" height="100" />
3. Run the report :)
-
hi!Alex! thanks for your reply. Now i have another question, could current designer design a report that content text, table and image.
-
cwl
Yes, it can.
-
Alex, thank you and your guys good job,thank you very much, and hope the project open source all the way.