Hand editing .ui files inside Qt editor - qt

I've been tweaking my .ui files by hand a lot recently and I'm curious, does anyone know how to turn off read only mode for .ui files in Qt Creator?
In case that's not immediately clear, what I mean is that .ui files (by default) are view-able inside Qt Creator but not write-able... and it's a minor nuisance to go boot up some other xml editor :/
Thanks!

In the context menu of any .ui file in the project explorer, click Open With and then Plain Text Editor. This gives you the same editor but with write mode.
Note that the disabled write mode for ui files when double clicking and changing to "Edit" mode rather than "Design" mode isn't a bug but a feature. Editing ui files by hand can destroy your file. At least, this is what the Qt guys think...

Related

How to use .ui.qml files from Qt creator version 6

I've been some reading/watching some tutorials here and there about qt quick and qml from last few days. But the user interface of qt creator, the boilerplate that it produces on a new qt quick project in each of the tutorial had been different. there's so much confusion.
I want to make a simple Hello World Qt Quick project, I followed this book from packt. (It has changed from the last time I saw it, but still doesn't work)
I added some a UI file, which added *.ui.qml and *form.qml files. Now if I edit .ui.qml in design, No change is reflected on any other file, but if I open some other file in design, it prompts me to use the .ui.qml file instead. The examples give an error "No Cmake config found". I'm using Qt6.2 on Arch/wayland, downloaded via installer.
How is it supposed to work? I have read this answer, and few others but I'm still confused.
Could you link to a proper tutorial, or a simple example?
The best way to think about it is that *.ui.qml should be used for UI elements and their settings. They should be about the structure, layout and styling of your UI. Doing that also happens to make the files presentable and editable in Creator's Design Mode since it simplifies the structure of the QML to the point where it can reliable present it and modify it.
*.qml files on the other shouldn't have UI elements and should instead primarily contain functions, properties and signal handers.
This pattern is sometimes referred to as "code behind". It sort of follows the same philosophy with HTML and CSS. Modern HTML documents primarily represent the structure of a page while CSS is placed in separate files to govern how they should be styled.
In this case *.ui.qml files contain the structure and styling while *.qml files containing the behavior. Creator will create a pair of them while adding a QML UI resource to your project where the .qml file inherits from the .ui.qml file.
Other than this inheritance and to encourage the code behind pattern, there's no real difference between a .qml and .ui.qml file. Creator will also try to steer you to the .ui.qml version of the pair when you go into designer to help encourage this pattern.
I will note that Qt violates this pattern a bunch all over their documentation and examples....

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

Qt Creator open ui.qml file in editor by default

In Qt creator whenever you open a ui.qml file by double clicking or CTRL + TAB the file normally opens in design mode. To see the code, you need to hit ESC to go the text editor. I want that the ui.qml files should open by default in the editor. How can I do that in settings?
In Qt Creator:
Tools >>> Options;
Open Environment;
Go to MIME Types;
Find (by filter, for ex.) application/x-qt.ui+qml;
Delete or change Pattern field in Details.
If you want to edit .ui.qml files by hand, don't use .ui.qml files?
These are made to be edited by the designer and are limited to a small subset of QML because of that.
Just use the normal .qml extension in this case.
More info on QML UI files here.

Removing QActions from the ui_mainwindow.h file

My app was started (by someone else) in Qt Designer. For a number of reasons I've decided to put the main form gui together in C++. In the designed I deleted all the gui widgets and removed the menu items from the object tree.
Having got the layout how I want it I started adding in the actions to find that they are still declared in the ui_mainwindow.h file.
Is it safe to manually remove the action declarations from this file? Or is there a way of doing this through Qt designer?
Open your *.ui file in the designer. In the lower right corner you'll see Action Editor. Actions can be deleted from there.

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.

Resources