I have this command to set label for all headers of a table:
ui.mytable->setHorizontalHeaderLabels(QStringList() << tr("VERTRAG") << tr("DATUM/UHRZEIT") << tr("PRÜFER"));
But this Ü does not appear. I tried to use
ui.mytable->setHorizontalHeaderLabels(QStringList() << tr("VERTRAG") << tr("DATUM/UHRZEIT") << tr("PRÜFER").replace(QString::fromLatin1("Ü"), "Ü"));
and
ui.mytable->setHorizontalHeaderLabels(QStringList() << tr("VERTRAG") << tr("DATUM/UHRZEIT") << tr("PRÜFER").replace(QString::fromUtf8("Ü"), "Ü"));
but it does not work also. How can I solve this?
ok, thank you guys. I have a simple answer. It works with me.
ui.mytable->setHorizontalHeaderLabels(QStringList() << tr("VERTRAG") << tr("DATUM/UHRZEIT") << QLatin1String("PRÜFER"));
Related
I am using nvidia nsight application to rotate and blur images. I am using the NPP libraries for the same,
The oDeviceDst gets filled the data from the output of function rotate, which is working fine.The code is shown below: Also note that the below piece of code is in a for loop for some rotation angles.
npp::ImageNPP_8u_C1 oDeviceDst(768 , 768);
Npp32s masksize = (Npp32s)KERNEL_LENGTH;
Npp32s anchor = (Npp32s)KERNEL_RADIUS;
NppiSize SzROI ={(int)oDeviceDst_gauss.width(),(int)oDeviceDst_gauss.height()};
std::cout << " anchor " << anchor << std::endl; std::cout << " masksize " << masksize << std::endl;
NppStatus status2 = nppiFilterRow_8u_C1R(oDeviceDst.data(), oDeviceDst.pitch(), oDeviceDst_gauss.data(), oDeviceDst_gauss.pitch(), SzROI, (Npp32s*)h_Kernel, masksize , anchor, int(sumh));
std::cerr << "status of blur is" << status2 << std::endl;
But as soon as i run it(remote on target), I get a status of -1000.
status of blur is -1000.
logout
Has anyone faced a similar issue in usage of NPP libraries.
When I execute following code:
bool ok = false;
QByteArray ba("fffff3");
qDebug() << ok << ba.toInt(&ok, 16) << ok;
The output is true 16777203 true,I vaguely know why.Someone can explain what is going on.What is ok's change process?
Is there any way to check properties and constraints for each column in a QSqlRelationalTableModel? For example, I'd like to ask my QSqlRelationalTableModel object whether a certain column can contain nulls, or what datatype is valid for that column.
You'll need to get a QSqlField value for each column of the model, which is given by
QSqlRecord record = model->database().record(model->tableName());
QSqlField field = record.field(columnIndex);
then you'll be able to check if a field can be null with QSqlField::requiredStatus() (if the driver supports querying that property) and to get its data type with QSqlField::type().
From alexisdm's answer above, I wrote this simple code snippet to output the properties of each field in a table. Posting it here to save typing for anyone else who is interested.
I also discovered a gotcha: if you use table_model::record() or table_model::record(int) you get unexpected (to me) results for some properties, e.g., isAutoValue seems to always return false, even for fields designated as autoincrement fields in the database. However, you do get a real value for typeID() (though I haven't been able to determine what typeID() is), whereas typeID() always returned -1 for me using model->database().record(model->tableName()).
QSqlRecord record = table_model->database().record(table_model->tableName());
// the following get isAutoValue() wrong; but have a real typeID()
//QSqlRecord record = table_model->record();
//QSqlRecord record = table_model->record(table_model->rowCount() - 1);
qDebug() << "********** table" << table_model->tableName() << "*********";
for (int i = 0; i < table_model->columnCount(); ++i) {
QSqlField field = record.field(i);
qDebug() << "---------- field" << i << field.name() << "--------";
qDebug() << "default value" << field.defaultValue();
qDebug() << "is auto value" << field.isAutoValue();
qDebug() << "is generated" << field.isGenerated();
qDebug() << "is null" << field.isNull();
qDebug() << "is read only" << field.isReadOnly();
qDebug() << "is valid" << field.isValid();
qDebug() << "length" << field.length();
qDebug() << "precision" << field.precision();
qDebug() << "required status" << field.requiredStatus();
qDebug() << "type" << field.type();
qDebug() << "type id" << field.typeID();
qDebug() << "value" << field.value();
}
i want to put a newline into a txt file, i tried with many alternative with so many help from this forum but i am getting always unknown character always. Please help
for (int i = 0; i < fileDet.size(); i++) {
qDebug() << "Name directory" << fileDet.at(i);
QFile data("output.txt");
if (data.open(QFile::Append)) {
QTextStream out(&data);
out << fileDet.at(i); //<<'\n';
out << QChar((int)'\n');
}
data.close();
}
Try out << endl;
When you open the file:
data.open(QFile::Append | QFile::Text)
I'm trying to free memory after using QList, but it doesn't seem to work properly.
Here's my code:
QList<double> * myList;
myList = new QList<double>;
double myNumber;
cout << "CP1" << endl;
getchar(); // checkpoint 1
for (int i=0; i<1000000; i++)
{
myNumber = i;
myList->append(myNumber);
cout << myList->size() << endl;
}
cout << "CP2!" << endl;
getchar(); // checkpoint 2
for (int i=999999; i>0; i--)
{
myList->removeLast();
cout << myList->size() << endl;
}
cout << "CP3!" << endl;
getchar(); // checkpoint 3
delete myList;
cout << "CP4!" << endl;
getchar(); // checkpoint 4
Memory usage:
CP1: 460k
CP2:19996k
CP3:19996k
CP4:16088k
So it looks like despite removing of elements and deleting myList still large part of memory is being used. I believe there is a way to handle it but I can't find it.
Thanks in advance for any help.
Pawel
Memory manager is not required to release the memory your program has allocated. There are no problems in your deallocation.
QList is an array based list. The array expands automatically, but does not shrink automatically. Removing elements from the list does not affect the size of the array.
To trim the array down to the actual size, create a new QList and add the contents to it. Then delete the original list.
Unfortunately looks like there is no convenience method to do this, like the List.TrimExcess() in .NET.