G
G
Gena2015-09-08 00:00:59
Qt
Gena, 2015-09-08 00:00:59

Why are images not added to widgets in QT Creator?

I looked on the Internet, it seems to be nowhere easier, but I rushed to make buttons with pictures and it started. Image added as a resource (in PNG format):

<RCC>
    <qresource prefix="/icons">
        <file>newfile.png</file>
    </qresource>
</RCC>

The image is not styled:
QToolButton {
    background-image: url(:/icons/newfile.png);
    border-style: solid;
}

The Icon property in the Designer is also not set. Although the resource is displayed in the list.
889d128f008441d8bfd9750bb9ab5eba.png
I tried various tips from the forums - pictures are not displayed either. Same story with QLabel. Maybe something needs to be added to the project or some additional library to put? Creator installed from the repository.
Distribution: Fedora 22 (KDE)
Of course, I want the picture to become through styles, otherwise it's a shame: There is a designer, but you can't design :(

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
Gena, 2015-09-09
@lukinov93

The problem was in the image itself. Other PNGs are loaded.

P
Pavel K, 2015-09-08
@PavelK

Try to put jpeg.
If it is installed, then for some reason the Qt lib for png support did not compile, but this is on the verge of fantasy.
Try to set the path to absolute as well.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question