0

How can I simply set background of my QDialog? I can easily set colour of background, but when i try use image, my background just goes black. I was trying to use: QPallete with QBrush, StyleSheets :(.

crooked
  • 675
  • 2
  • 11
  • 22

1 Answers1

1

You can simply

MyDialog::MyDialog(QWidget *parent)
    : QDialog(parent)
{
    ui.setupUi(this);

    setStyleSheet( "background-image:url(image.jpg);" ); //this works
}

See also: Unable to set the background image in Qt Stylesheet

Community
  • 1
  • 1
Vladimir Bershov
  • 2,701
  • 2
  • 21
  • 51
  • Unfortunately it doesnt work :/ I have my .jpg in resources, path is correct and nothing changes on my background :( – crooked Jan 22 '17 at 20:45
  • @KCrookedHand - Did you deploy the imageformats folder with your app? See also [autoFillBackground](http://doc.qt.io/qt-5/qwidget.html#autoFillBackground-prop) and [Qt Image Formats](http://doc.qt.io/qt-5/qwidget.html#autoFillBackground-prop) – Vladimir Bershov Jan 22 '17 at 20:47