How can i open printdialog in this style?
thanks,
That's the GTK print dialog. To use that style in Qt you would need to write your own class and encapsulate GtkPrintUnixDialog (and link in the GTK libraries)
Related
I am new to QML, so I wanted to ask .. is it possible to import/convert/use CSS templates in QT ?
because I found many stylish CSS component. more than QML templates.
QML by default allows CSS styling with limited options. The limitations are mentioned here.
But if your intention is to add a .css file into the project and make that as a style sheet then there is no default way.
Here is the out of the box project with GitHub, which allows direct integration of CSS style sheets into QML. You can refer to the examples in that project
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.
There's anyway to add a custom font (Such as Console Font) to Qt? How? And how do we set it to a Text Editor (QPlainTextEdit, QTextEdit, etc)?
Thanks
Qt uses your window system as a font provider. You can find out all the fonts available by using the QFontDatabase class. Anyway, it is possible to add a specific custom font for your application to use using QFontDatabase::addApplicationFont from C++ (available under X11 only if fontconfig is available) or using the FontLoader component in QML.
For QTextEdit you can use this and for QPlainTextEdit you might try the font property.
Is there a stylesheet available for use in Qt applications (through Qt Creator) that makes your GUI use the stylesheet you see in Qt Creator itself, as well as in AutoCAD and some other applications?
What is the name of that stylesheet or where can I get it? It looks much like the Vista stylesheet though...
And whenever you set a custom stylesheet to your Qt application, will it display the same style on all platforms, or will it still display native GUI parts?
To the people that may want to find out more: The style seems to be called manhattanstyle and extends QWindowsStyle. It is not a css-stylesheet and therefore not just copy and paste to set up. It seems to have some other dependencies in the source code, so I don't know how much it will take to adapt it.
The source is found in the [qt-creator source code]/src/plugins/coreplugin/manhattanstyle.cpp
And btw: if you are running debian/ubuntu: type apt-get source qt-creator to get the source ;)
I can't say as to how you would get style sheets that match Qt Creator or AutoCAD but to answer your other question: When you apply a style sheet, it applies to the object you applied it to, and the child hierarchy of that object. Any widget not addressed by the style sheet in some way will maintain the native look and feel that matches the Style (not style sheet) chosen by Qt as most appropriate for you application based on the user's platform and desktop environment.
yes, somebody has separated it out.
see this Manhattan style
I'm new to Qt and have been designing forms using Qt Creator. I've noticed that I can apply styles for specific widgets in the form's stylesheet, and it will style every widget on the form. For example "QPushButton{color: red;}" will make all the QPushButtons on the form have red text.
Is there a way to only apply styles to certain groups of widgets? For example, if I promote a QPushButton and call it MyButton, how can I set styles only for MyButtons. I would expect to be able to do something like "MyButton{color: green;}" but that doesn't seem to work.
Is there a better way to do what I'm trying to do (preferably using Qt Creator)? I can't seem to find an example of this anywhere, but maybe it's because I'm not using the correct terminology.
Thanks,
Mark
There are a lot of options for specifying selectors in style sheets. They are documented here.
One that I use (that is hinted to in the official style sheet reference document) is
|=
QPushButton[objectName|="somePrefix_"]
I use this to select items that have the same object name prefix. You could of course achieve a similar thing by applying a stylesheet to a panel containing the buttons you want to style differently but this can get tricky.
IIRC that should work, but creator might not show the preview correctly as it is not instantiating your button. Personally I think working with a global .css file that gets loaded at startup works better than applying single styles on each element in creator.
Use QApplication::setStyleSheet() to set a global stylesheet