what qwidget subclass?
-
but QPixmap can load from QString only, that's why i changed it from QIcon.
and yes, i'll need to load external files too so that's another problem
-
@user4592357
Hi
If you need to load external files, where will they be placed ?
The user will point to them ?Using a Resources file, includes the images in the exe file and can be loaded with QString and pixmap.
-
the user will provide a path to the image, and i should go get the image from the path and display it in the widget
EDIT: i was able to draw using an entry from qrc but what should i do with that user provided icon paths?
-
Ok, sounds like a normal file open dialog
http://www.codebind.com/cpp-tutorial/qt-tutorial/qt-tutorials-beginners-qfiledialog-getopenfilename-example/Then load it via pixmap. Should just work.
-
@user4592357
Ok, i see no reason it should not work if the paths are fully qualified and
valid.I would test that
qDebug() << "loading: " pixmap.load(iconPath);
says true
also i would try with#include <QFileInfo> bool fileExists(QString path) { QFileInfo check_file(path); // check if file exists and if yes: Is it really a file and no directory? return check_file.exists() && check_file.isFile(); } and check iconPath where u try to load the image.
Also where does icon-full-path come from ?
Is it in the app or do you load from text file ? -
thanks. i'll read a text file for that, but why does that matter?
-
@user4592357
Well if inside the app you must escapec:\\xxx\\cyy\\
But that is not valid if from text file so just asking to try to guess reason that is not shown :)
-
QFile::exists() gives false when i use a full path for the image (like, C:\Users\user\image.png). but the file sure exists. i've tried using \\ instead of \, also / but not much success. with resource system, however, everything is okay
-
@user4592357
if you take one of the paths from the file
and start paintbrush, select file->open
and paste the path into the filename area. and then press open.
will it then open ?it sounds really, really wrong if QFile::exists() says false.
-
Hi
Did you try to qDebug() << file.filePath();
to see if anything still 100% like the one in file? -
@user4592357
Really cannot guess then.
If path in text file truely are valid syntax, it should just work.
and you are 100% sure you escape it ?
( which is needed when inside the code, but from text file)setIcon("C:\\Users\\user\\image.png");
-
@user4592357
I have done it many times so I do
wonder what you do that is
different or if it really just is a path issue. -
Hi,
Since you are using Qt, why not use the Unix notation ? Qt handles the conversion when it calls the related platform specific functions.
So it should be
C:/Users/user/image.png
-
Does that file have any permission issues ?
Are you 100% sure that it's there ?
Are you loading it from your own user account ?
Any special char in the path ? i.e is user really the account name ?