Open ArsMasiuk opened 4 years ago
Hi! I can't reproduce the problem Could you show me a code of how you use limereport?
Hi, I've just took an example from the main page:
LimeReport::ReportEngine *report = new LimeReport::ReportEngine(this);
report->loadFromFile("C:/Test/Test Report.lrxml");
report->previewReport(&printer); // here comes no preview
report->printReport(&printer); // here nothing happens as well
It looks like all right with your code but something wrong with the report file.
Could you change your code like this?
QString reportName = "C:/Test/Test Report.lrxml";
if ( QDir().exists(reportName) ){
if (report->loadFromFile(reportName)){
report->previewReport(&printer);
report->printReport(&printer);
} else QMessageBox::warning(this, "Warning","Something is wrong with the report file");
} else QMessageBox::warning(this, "Warning","The file does not exist");
Sure, the report file exists. I've attached it to the ticket. I've just started the LimeReport Designer and added single static text label to a header band. The Designer shows up the preview just as expected, but the same report cannot be viewed/printed from the code. loadFromFile() returns true in my case.
I'm very surprised. I have checked the attached template and for me, limereport shows a preview without any problem. Could you check if the demo_r1 will show the report?
Yes, it works from demo_r1. But it does not work from a standalone project. Maybe it has something to do with the printer object, however it is only PDF file printer in my case...
You can check it, just call report->previewReport();
Hi, same problem, demo works perfect, but preview in my project not working. Nothing happens on report->previewReport();
@Joyker Even if you just put some TextItem with some text and run preview?
@fralx Yes
@Joyker If I understand you right, you built the demo_r1 and it works as expected, but your own project not?
I have exactly the same issue, Windows 10 64 bit, visual studio 2017
On Wed, Dec 30, 2020, 14:03 Alexander Arin notifications@github.com wrote:
@Joyker https://github.com/Joyker If I understand you right, you built the demo_r1 and it works as expected, but your own project not?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fralx/LimeReport/issues/301#issuecomment-752567119, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEWY5KH2TAZLODAXCS7ZPYLSXMQI3ANCNFSM4S4GLIWA .
@ArsMasiuk, @Joyker, could I ask you to check somesthig like this report->designReport(); report->previewReport();
will it show preview window?
@ArsMasiuk, @Joyker, could I ask you to check somesthig like this
report->designReport(); report->previewReport();
will it show preview window?
sorry, my bad, i had an issue with report path. Now i can`t make work signal slot report. Is there any example for it ?
@Joyker You can look at demo_r1 ("oneSlotDS").
oneSlotDS
I see, but still has no success, i have no database, only List
@Joyker Could you explain to me where are you sticking? Using "OneSlotDs" approach you can provide any type of data to limereport.
void MainWindow::slotOneSlotDS(LimeReport::CallbackInfo info, QVariant &data){
QStringList columns;
columns << "Name" << "Value" << "Image";
switch (info.dataType) {
case LimeReport::CallbackInfo::RowCount:
data = 4; // this case should return how many rows will be in the dataset
break;
case LimeReport::CallbackInfo::ColumnCount:
data = columns.size(); // this case should return how many columns will be in the dataset
break;
case LimeReport::CallbackInfo::ColumnHeaderData: {
data = columns.at(info.index); // this case should return header name or in other words field name
break;
}
case LimeReport::CallbackInfo::ColumnData:
// this case should return data for column identified by info.columnName and row identified by info.index
if (info.columnName == "Image")
data = QImage(":/report//images/logo32");
else {
data = info.columnName+" "+QString::number(info.index);
}
break;
default: break;
}
}
@Joyker Could you explain to me where are you sticking? Using "OneSlotDs" approach you can provide any type of data to limereport.
void MainWindow::slotOneSlotDS(LimeReport::CallbackInfo info, QVariant &data){ QStringList columns; columns << "Name" << "Value" << "Image"; switch (info.dataType) { case LimeReport::CallbackInfo::RowCount: data = 4; // this case should return how many rows will be in the dataset break; case LimeReport::CallbackInfo::ColumnCount: data = columns.size(); // this case should return how many columns will be in the dataset break; case LimeReport::CallbackInfo::ColumnHeaderData: { data = columns.at(info.index); // this case should return header name or in other words field name break; } case LimeReport::CallbackInfo::ColumnData: // this case should return data for column identified by info.columnName and row identified by info.index if (info.columnName == "Image") data = QImage(":/report//images/logo32"); else { data = info.columnName+" "+QString::number(info.index); } break; default: break; } }
callbackDatasource = m_report->dataManager()->createCallbackDatasource("master"); conect the slot i can print report variable but data..
In report i have text field with $D{master.test} and $D{master.test2} and switch like
switch (info.dataType) {
case LimeReport::CallbackInfo::ColumnCount:
qDebug()<<"called column count";
data = 2;
break;
case LimeReport::CallbackInfo::RowCount:
qDebug()<<"called row count";
data = 1;
break;
case LimeReport::CallbackInfo::ColumnHeaderData:
qDebug()<<"called column header";
data = "header_123"; // not sure what is this..
break;
case LimeReport::CallbackInfo::ColumnData:
qDebug()<<"called column data";
if (info.columnName == "test")
data = "it works!";
else
data = "42";
break;
}
and Filed master.test not found in TextField1 as a result
I see. Let me explain where you wrong
// In your case just add these lines (for example) ----
QStringList columns;
columns << "test" << "test2"; //column names or filed names like you wish
// ----
switch (info.dataType) {
case LimeReport::CallbackInfo::ColumnCount:
qDebug()<<"called column count";
data = 2;
break;
case LimeReport::CallbackInfo::RowCount:
qDebug()<<"called row count";
data = 1;
break;
case LimeReport::CallbackInfo::ColumnHeaderData:
qDebug()<<"called column header";
// data = "header_123"; // not sure what is this..
data = columns.at(info.index);
// this case should return "test" and "test2" as you used $D{master.test} and $D{master.test2}
break;
case LimeReport::CallbackInfo::ColumnData:
qDebug()<<"called column data";
if (info.columnName == "test")
data = "it works!";
else
data = "42";
break;
}
Thank you, it worked, but i have last question.
I have added list model (let`s assume my complex model from api just string list)
QStringList columns;
columns << "test" << "test2"<<"item";
QStringList list;
list<<"item1"<<"item2"<<"item3";
switch (info.dataType) {
case LimeReport::CallbackInfo::ColumnCount:
data = 3; // 3 column in data band ?
break;
case LimeReport::CallbackInfo::RowCount:
data = 3; // 3 item expected in report
break;
case LimeReport::CallbackInfo::ColumnHeaderData:
data = columns.at(info.index);
break;
case LimeReport::CallbackInfo::ColumnData:
if (info.columnName == "test")
data = "it works!";
else if (info.columnName == "item")
data = list.at(info.index);
else
data = "42";
break;
}
but i see ony first item record.
Did you place your TextItems on a DataBand if yes, check please if the DataBand property datasourse is initialized by value "master"
Did you place your TextItems on a DataBand if yes, check please if the DataBand property datasourse is initialized by value "master"
Thank you, it worked
I am really sorry for bothering again, but i have no idea. I have sample project and it works as expected I have added LimeReport to work project, i am sure about correct include path and so on, but ... I have succesfull build&compile and crash on start (first window is login, it does not use LR)
I commented everything devoted to lime report and begin uncomment line by line
m_report = new LimeReport::ReportEngine(this);
If only i have this line, everything goes wrong, without any message.
sample project has the same qt version, compiler
hope for your help
Hi! It`s hard to say what happens without your source codes. Check please if the limereport shared library is accessible for your executable binary
I found a problem, if there are LimeReport and QtRpt at the same time you will get crash on start without any messages. Building a disto you`ll see some error in QtZint, it seems QtRpt and LR need different versions.
LR using signal-slot mechanims works with the same perfomance as QtRpt (100 pages per second or so), but unlike QtRpt don`t shows "Window not responding" messages.
I didn't use QtRpt could you explain to me what do mean " don`t shows "Window not responding" messages"? It's about freezing the user interface?
A simple report (only one page with static header) is visible in Designer. However it is impossible to preview & print it out from the code. page->isPrintable() is always returning false, however "printable" property is set to "1" in the xml.
test.zip