751
Discussion | Обсуждение / Re: Соединения с БД
« on: December 27, 2016, 08:01:06 PM »
Повторить не удалось. Можете в режиме отладки посмотреть место в котором крашится ?
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
if (db.open())
{
m_customers = new QSqlQuery(m_strQuerySql, db);
QSqlQueryModel* customersModel = new QSqlQueryModel();
customersModel->setQuery(m_strQuerySql);
report->dataManager()->addModel("ds1", customersModel, true);
report->loadFromFile(m_strReprotName);
report->previewReport();
delete customersModel;
};
delete report;
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?
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;
}
}
data should be false otherwise callback dataset will be emptyCode: [Select]case LimeReport::CallbackInfo::IsEmpty:
qDebug() << "P2 IsEmpty - r " << this->_currentRow << " - " << info.columnName;
data = true; //!ds->first();
break;
void ReportsGenerator::LRGetCallbackData2(LimeReport::CallbackInfo info, QVariant &data) {
switch (info.dataType) {
case LimeReport::CallbackInfo::RowCount:
qDebug() << "P2 RowCount - i" << info.index << " - " << info.columnName << " - r " << this->_currentRow;
data = 4;
break;
case LimeReport::CallbackInfo::ColumnCount:
qDebug() << "P2 ColumnCount - i" << info.index << " - " << info.columnName << " - r " << this->_currentRow;
data = 5;
break;
case LimeReport::CallbackInfo::IsEmpty:
qDebug() << "P2 IsEmpty - r " << this->_currentRow << " - " << info.columnName;
data = false; //!ds->first();
break;
case LimeReport::CallbackInfo::ColumnHeaderData: {
switch(info.index) {
case 0:
data = "Name1";
break;
case 1:
data = "Value1";
break;
case 2:
data = "Name2";
break;
case 3:
data = "Value2";
break;
case 4:
data = "SamplesGroup";
break;
}
qDebug() << "P2 HeaderData - " << info.index << " - " << data.toString();
break;
}
case LimeReport::CallbackInfo::ColumnData:
qDebug() << "P2 Requested - i - " << info.index << " - " << info.columnName << " - r " << this->_currentRow;
if (info.columnName == "SamplesGroup")
data = "Resultados Gerais";
else {
data = "Data";
}
break;
default: break;
}
}
Если просто $D{table_model.4} выводит все правильно (0, 1, 2), а с условием все время в else попадаетИз этого я делаю вывод, что данные проброшены нормально
$S{
if({$D{table_model.4}}=='0')
"<img src='/home/dark/Pictures/Icons/chip_1.png'>"
else ""
}