File path does not show correctly in QLabel
-
I have a QLabel in my app. It shows the corresponding image path. But I found sometimes it misses a '\' .
My Pyside6 version is 6.3.2. And I found that if the file name does not start with '#', it shows right. -
@feiyuhuahuo How do you create the path?
-
@feiyuhuahuo
As @jsulm says.After that, for the record: since you say
#
is special, be aware that if you start from or use a URL then that character has special significance, as it looks for a n HTML bookmark on the page. Is this maybe relevant to your situation? -
@JonB The image name sometimes starts with a
#
by chance. I can't decide this. The situation is that, I have a lot of images in a folder, I useglob.glob()
to get their paths. Some of them start with a#
, but I want them to show correctly. -
@feiyuhuahuo
As a small point: if you are usingglob.glob()
(presumably not under Linux but under Windows from what I see), or indeed anything else, you really ought not produce paths which have a mixture of/
s in the leading path and\
s in the trailing path, in just leads to confusion/complications.I now understand that if you have
\OK\1#
that shows correctly onQLabel
, but if you have\OK\#
that shows as\OK#
. Try one of the following:QLabel::setTextFormat(Qt::PlainText)
. I would actually hope this works and is all you need?- Change the
\
s to/
s. - Change
\#
to\\#
.
Do any of these resolve your problem?