Problem with ressource file
-
Hello :)
I'm having trouble adding images in qt projects, through qrc files. I'm trying to add an image to a label, but can't do it. I click on "Copy path", paste it in the code, but when running the label remains blank. I tried adding an additional '/' but it's not working. If I enter the absolute path(C:\User...) I can see the image. -
Hello :)
I'm having trouble adding images in qt projects, through qrc files. I'm trying to add an image to a label, but can't do it. I click on "Copy path", paste it in the code, but when running the label remains blank. I tried adding an additional '/' but it's not working. If I enter the absolute path(C:\User...) I can see the image. -
Hi and welcome to devnet,
Can you share the content of the file ?
And an example of line you use to load an image in a QLabel ?
-
Hi and welcome to devnet,
Can you share the content of the file ?
And an example of line you use to load an image in a QLabel ?
@SGaist
File untitled3.pro:#-------------------------------------------------
Project created by QtCreator 2016-07-25T14:54:55
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = untitled3
TEMPLATE = appSOURCES += main.cpp
mainwindow.cppHEADERS += mainwindow.h
FORMS += mainwindow.ui
RESOURCES +=
ress.qrc
Here I load the pic in the QLabel. It's also highlighted in the image in the first post:
ui->pic->setPixmap(pic.scaled(ui->pic->width(),ui->pic->height(),Qt::KeepAspectRatio));
ui->pic is the QLabel
pic is the QPixmal created above. -
The code in the screeshot looks fine.
Did you specify an alias in the qrc-file?
Can you paste the plaintext content of the qrc-file? -
Is rcc run on the resource file at all?
qmake is terrible at detecting changes in the .pro file, try clearing everything and then rebuild
-
Also, the .pro file that you posted should not work correctly. Newlines in pro files are the same as
;in C++RESOURCES += ress.qrcshould become
RESOURCES += ress.qrcsame as
SOURCES += main.cpp mainwindow.cppshould become
SOURCES += main.cpp \ mainwindow.cpp -
Also, the .pro file that you posted should not work correctly. Newlines in pro files are the same as
;in C++RESOURCES += ress.qrcshould become
RESOURCES += ress.qrcsame as
SOURCES += main.cpp mainwindow.cppshould become
SOURCES += main.cpp \ mainwindow.cpp -
@VRonin I've rebuild the project, still can't see the image. I'll try on a fresh project right now.
-
Also, the .pro file that you posted should not work correctly. Newlines in pro files are the same as
;in C++RESOURCES += ress.qrcshould become
RESOURCES += ress.qrcsame as
SOURCES += main.cpp mainwindow.cppshould become
SOURCES += main.cpp \ mainwindow.cpp