How to link external qss Stylesheet inside QT designer .ui file - qt

I have downloaded these stylesheets of QT designer: https://github.com/Alexhuszagh/BreezeStyleSheets
And I would like to link the qss file "dark.qss" directly in the .ui file in the QT designer, "Edit Style Sheet" Menu.
The stylesheet has a resource "qrc" file which is recognized by QT designer. And in the "Edit Style Sheet" Menu I see the option to select the dark.qss file. The only problem is I get an error "Invalid Style Sheet" when adding it with url.
I have tried copying the content of dark.qss directly in the "Edit Style Sheet" Menu. And this works. It actually changes the style. But I would prefer to have a link to the qss file instead of the complete code.
Is it possible to link the qss file using the "Edit Style Sheet" Menu?

No, You can not. You have to load the file using QFile and load it into app as the README of the repository shows.

Related

Icon doesn't display in qt designer made dialog for QGIS

this is my first QT designer project, and I haven't found an answer for my problem, I designed a dialog for QGIS, I included an icon, with the label display widget, set it up from the resource file, but it won't show in QGIS, at first it didn't even recognized the font and font size I set up in QT, but changing the style Sheet directly in the object inspector fixed that, now I just can't make the icons appear in QGIS, I tried .png and .ico and minimal size, I tried editing the .qrc and .ui file, but nothing works, do I need a python script for that?, what am I missing??
When I preview the dialog in QT it shows ok, and the deafult icons appear in QGIS
I am using QGIS 2.18 and QT designer 4.8.5
Thanks
After you have replaced the icon file you need to recompile with the command make

How record Qt Widgets StyleSheet in a sepatated file

Is it possible to get the stylesheet from a separated file for a Qt Widgets application, like .CSS does to .HTML ?
Yes, it is possible. You may load any file with QFile and use setStyleSheet method in your application or any widget. by #SaZ

Qt-Creator: How to set a application wide style sheet that can be seen in QTDesigner?

With
void QApplication::setStyleSheet()
I can set a global style sheet for my Qt application.
For example, I set the default background of all QWidgets to black.
However, in the QT Designer all my widgets still have the default looks (grey background), because it doesn't know anything about my code.
Is there a way to set a global style sheet to my application that also affects the widgets looks in the QT Designer? Then I wouldn't have to compile my project every time I want to see how it looks.
Or is there maybe a more sophisticated way to solve this problem?
There is solution. You can set in Qt Designer your stylesheet for top level widget styleSheet property.
For example: you set style
QWidget {background-color:black;}
for MainWindow form in Qt Designer and all child widgets now have black background.
In the Preferences dialog (menu: Settings, Preferences...), there's a section in Forms called "Print/Preview Configuration". You can set a stylesheet there for the preview action (normally on Ctrl+R). This won't change the colour of the form as you edit it, but you can quickly see it as it will appear in your application.
See also my question Can I style the top-level form in Designer preview?
As you said yourself: It doesn't know anything about your code. So nothing you can do in code. But compiling your project every time you want to see how it looks? One stupid question... don't you know about the preview function in the designer? Press ctrl-alt-r.
Of course, it shows only the style, which is applied to the widget currently loaded in the designer. But you could temporarily set your style sheet to this widget to see how it would look, if you later on set this sheet globally in your program. Not perfect, but at least no need to compile your whole project.

Customise QPushButton with an image

I am using Qt5 and having some problems in setting the back ground image of a QPushButton. I am using Qt Creator and Design to drag and drop the QPushButton. After that I created a source folder and placed an image in that directory and I googled and tried doing
ui->pushButton_play->setStyleSheet(QString::fromUtf8("background-image: url(:/source/play.png);"));
but no success...am I creating the folder in a wrong place?..I created in D:\Qt5_PROJECT_NAME\source or will I make the url(:\\source\\play.png). Nothing is working...please help...
Did you add the images file into .qrc file? A URL start with : has indicated that It will be searched in .qrc file. If .qrc file didn't used, URL should not start with :. Maybe you should access the image file as
ui->pushButton_play->setStyleSheet(QString::fromUtf8("background-image: url(source/play.png);"));
This is The Qt Resource System documentation.

How can I set the Eclipse JS to edit a file as CSS

I use the lesscss, it's works fine, but the Eclipse editor doesn't highlight the words, and the Zen Coding doesn't recognize that a css file. How can I open the .less file as a .css file?
Any help would be appreciated.
I found the solution: in the general menu -> content types option I can add a file association to the css content type.

Resources