please note: QT newbie
I am attempting to display a PNG on a qLabel using the setPixmap function.
note: PNG dimensions < Label dimensions
Following this example, it is supposed to display the image, but I have no luck.
I have attempted many examples, from using QImage to using GraphicsViews,etc.
I have gotten this image to show by specifying the full path in the QPixmap pixmap("full_path_here")
, thus wanting to get rid of the full path, attempted adding this image to a resource fill, aka .qrc
but the error below persists, I have no idea why.
ERROR: /opt/qt/Qt5.7.0/5.7/gcc_64/bin/rcc:-1: error: No input files specified.
mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QPixmap mypix (":/back.png");
ui->label->setPixmap(mypix);
}
MainWindow::~MainWindow()
{
delete ui;
}
.qrc resource file
<RCC>
<qresource prefix="/">
<file>back.png</file>
</qresource>
</RCC>
mainwindow.ui
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>90</x>
<y>20</y>
<width>131</width>
<height>121</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
Project Location:
ll /home/cx/qt-projects/VPN/
total 48
drwxrwxr-x 1 cx cx 162 Oct 5 15:53 ./
drwxr-xr-x 1 cx cx 90 Oct 5 12:21 ../
-rw-rw-r-- 1 cx cx 1514 Oct 5 15:33 back.png
drwxrwxr-x 1 cx cx 108 Oct 5 12:12 .git/
-rw-rw-r-- 1 cx cx 172 Oct 5 10:41 main.cpp
-rw-rw-r-- 1 cx cx 393 Oct 5 15:53 mainwindow.cpp
-rw-rw-r-- 1 cx cx 399 Oct 5 15:25 mainwindow.h
-rw-rw-r-- 1 cx cx 3134 Oct 5 12:21 mainwindow.ui
drwxrwxr-x 1 cx cx 8 Oct 5 12:11 res/
-rw-rw-r-- 1 cx cx 400 Oct 5 12:12 VPN.pro
-rw-rw-r-- 1 cx cx 24064 Oct 5 12:35 VPN.pro.user