How to properly change font weight in model?
I am having issues setting font weight for a column inside QTableView's model.
I found that I can use QFont for it, but I cannot find a way to set only the font weight, I want the text bolded for some cells.
I tried it like this:
Code:
if(index.column() == 5){
if(role == Qt::FontRole){
int valStare
=QSqlQueryModel::data(index, Qt
::DisplayRole).
toInt();
// to check which cells to modify in the column int marime=info.pointSize(); //tried also pixelSize();
if(valStare==1)
}
}
return value;
}
But the font is different from the rest of my tableview.(Is it setting the font size and family to what I am using on my OS?)
Any suggestions?
Re: How to properly change font weight in model?
You are getting font info from the database but you are not applying to to all columns.
If you always want to use the font specified in the database then you have to answer FontRole for all cells. You can still change it for the cells you want bold of course.
Btw, are you sure that the value returned by the base class is both a number and a font family? Usually font families are not just numbers.
Cheers,
_
Re: How to properly change font weight in model?
Oh, I misunderstood the usage, I was trying to get the font from the tableview, but it takes the font from database.
Though I do not understand:
Quote:
Btw, are you sure that the value returned by the base class is both a number and a font family? Usually font families are not just numbers.
I use:
To check the value returned by the query which is 0 or 1 so it knows wether to change the font or not.
is used to get font info like font family and size, though now I understood that it took the fony from the database and not the application itself(more exactly the QTableView).
Re: How to properly change font weight in model?
If you don't have font information in the database, it might be easier to do the visual differentiation with an item delegate for the respective column.
Cheers,
_
Re: How to properly change font weight in model?