QGraphicsSimpleTextItem not outlined
-
I would like to bump this. I've actually tried to make the font bold, and I was hoping to kind of solve the problem this way. But I couldn't, neither on Ubuntu 15.04 nor on Ubuntu 14.04 LTS. The lines
otherFont.setBold(true); otherFont.setWeight(99);
do not seem to work at all (either one). Any ideas?
-
@Pippin
Hi
maybe try with some other font.
on windows 7, the outline is really a outline
http://postimg.org/image/b7bpxabwl/
Update:
Also tried Chis code in ubuntu.
Look 100% the same as in win 7. -
@mrjj I've tried different fonts and the result is always the same. If the width of the QPen gets thick enough, the entire text is filled with the pen's color.
Edit: Are you sure you don't have the same problem? The way the blue is drawn around the 9 makes me believe that it is drawn inside the characters too.
-
@mrjj Could you try the same code you used but with
QPen(Qt::blue, 50)
please? The way the blue is drawn in the corner of the number '9' seems to indicate that you actually have the same problem. Not sure how to word this, just tell me if that still works correctly for you.If everything works on your computer with Ubuntu, it really should be the same on mine...
-
@Pippin
Well at small size it does overlap
http://postimg.org/image/ywjidp6pt/
also if big pen, then it overlaps.
http://postimg.org/image/wtn3l0m3n/So yes, you are right. its really not a true outline.
-
I believe that's how an outline is suppose to work. It outlines the path that forms the letter, not the filling, so if the letter has a filling brush the outline will go both inside and outside of it:
The red line is a path that forms the letters.
-
@Chris-Kawa Does this mean that there's no real solution to my problem? I can't outline my text without "eating" it just as much as I outline it?
Or maybe I could print it twice so that the inline is hidden by the second text ---> Haha I've just tested this and it works. Totally makeshift but it works.
-
@Chris-Kawa
Hi, can I ask how u get it to show the path ? -
@mrjj I just created two items. The second one with no filling and a cosmetic brush (1px):
auto item = w.scene()->addSimpleText("ABC99", QFont(QString(), 100)); item->setBrush(QBrush(Qt::white)); item->setPen(QPen(Qt::blue, 8)); auto item2 = w.scene()->addSimpleText("ABC99", QFont(QString(), 100)); item2->setBrush(QBrush(Qt::transparent)); item2->setPen(QPen(Qt::red, 0));
but that's just to quickly show what I mean. I don't claim it's a good way to do it in general.
@Pippin I guess that's one way to do it. It's a shame since you pay a doubled cost of stroking the path for each text, but I couldn't find a better way to do it. I thought of using a two-color gradient for the outline, the inside one using the filling color, but there doesn't seem to be an easy way to make the gradient follow the path. Oh well. if it works it works.
-
ahh. i see. thank you.
Was not aware of the cosmetic pen function.