setStyleSheet set the background image

Set the background color is simple. Most tutorials have a small dip on the background image. Background image, there are two main cases, the first: the absolute path of the pictures `` `this-> setObjectName (" mainWindow "); this-> setStyleSheet (" # mainWindow {border-image: url (/ home / kylin / 2.png);} ");` `` in the url brackets directly to the absolute path to Nianshang Qu; second: the relative path, for portability program, and certainly can not say the picture is set to an absolute path, so right point your project "Add New" -> "QT resource file" qrc generate a file and double-click it and then add points Add Prefix Add file is then added a resource file in the resource file to add pictures inside `` `this-> setObjectName ( "mainWindow"); this-> setStyleSheet ( "# mainWindow {border-image: url (: / new / prefix1 / 2.png);}"); `` `url brackets so that the relative path, / new / prefix1 is to add a new file prefix when made in qrc file name prefix (the default). Note that the parentheses Riga ":" and there is no difference between plus there is a problem please add me to explore: Contact: 18373370753 (qq micro letter of the same number)

Guess you like

Origin www.cnblogs.com/hepuyao/p/11610161.html