About background-image jpg file / QMainWindow

273 views
Skip to first unread message

Javier

unread,
Nov 6, 2016, 1:13:59 AM11/6/16
to QtContribs
Hi,
This code works well when the image is a png file, but if I try to use an image jpg file the image is not displayed,
main_window := QMainWindow()
main_window
:setMinimumSize(350, 350)
main_window
:setMaximumSize(350, 350)
main_window
:setAttribute(Qt_WA_DeleteOnClose, .f.)
main_window
:setWindowTitle("test")
main_window
:setObjectName("ventana_principal")
main_window
:setStyleSheet( 'QMainWindow#ventana_principal { background-image: url("resource/images/harbour.png"); background-repeat: no-repeat; ' + ;
                               
'background-size: containt }' )

There anything special need to consider to use jpg image files?, I have also tried:
palette := QPalette()
palette
:setBrush(QPalette_Background,QBrush(QPixmap("resource/images/img.jpg")))
main_window
:setPalette(palette)



or

imagen := QImage("resource/images/img.jpg")
brush
:= QBrush(imagen)
main_window
:setBackgroundBrush(brush)



And nothing seems to work correctly, some indication here please.

Regards,
Javier

 

Francesco Perillo

unread,
Nov 6, 2016, 4:59:02 AM11/6/16
to qtcontribs

If i remember correctly there is a plugin for jpeg..


--
You received this message because you are subscribed to the Google Groups "QtContribs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qtcontribs+unsubscribe@googlegroups.com.
To post to this group, send email to qtcon...@googlegroups.com.
Visit this group at https://groups.google.com/group/qtcontribs.
For more options, visit https://groups.google.com/d/optout.

Pritpal Bedi

unread,
Nov 6, 2016, 10:39:05 AM11/6/16
to QtContribs
Hi


In the folder where your .exe resides 
( unless you are executing it while staying in Qt's bin folder ) 
create folder plugins/imageformats and copy therein relevant .dlls 
from Qt distribution.


Pritpal Bedi

Javier

unread,
Nov 7, 2016, 12:18:14 PM11/7/16
to QtContribs
Hi,
Thank you both, in my case it did not work with the folder structure plugins/imageformats, it worked well only creating the imageformats folder.

I appreciate your help.

Regards,
Javier
Reply all
Reply to author
Forward
0 new messages