Removing QActions from the ui_mainwindow.h file - qt

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.

Related

No headers or source files in QT creator

I'm having a problem with creating new header and source files in QT. I can only add new files to the build, it's grayed for the "main" project as you can see below.
I can create them specifically for the build and they only appear once in the documents area. There is no header tree branch. After I close qt I have to create new ones. I want them to appear in the tree and be connected with the main project. I have "hide source and headers files" option off.
I've obviously tried creating them the way it was shown on the yt. I've searched through settings but didn't found anything I could use.
You will have to add the files manually in CMake.
Go to File>New File and select what type of file you want. Typically it will be a source, header, or both (class).
Edit the CMakeLists.txt file:
qt_add_executable(myapp
myapp.qrc
main.cpp
new_file.cpp
new_file.h
)
Resources like .qml files and things like images (*.png *.jpg) are added in the myapp.qrc file

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....

Qt Virtual Keyboard Custom Style

I need to build a custom Style for a Qt VirtualKeyboard on a small screen to maximize its readability. I have built a custom layout into my project, and using the QT_VIRTUALKEYBOARD_LAYOUT_PATH it works great.
The problem I am having is that the documentation states that the custom style must be placed in the Qt Directory. I need this style to be portable, however, so storing this newly built style on my local machine, rather than in the project itself, will not be acceptable.
Is there any way to build a use a keyboard style within a project?
It doesn't have to be in the Qt directory, just in a directory that is under QtQuick/VirtualKeyboard/Styles/ and in the QML import path.
As an example, take a look at the auto test:
http://code.qt.io/cgit/qt/qtvirtualkeyboard.git/tree/tests/auto/styles/data
You can also put the style in a .qrc file under that folder structure:
http://code.qt.io/cgit/qt/qtvirtualkeyboard.git/tree/src/virtualkeyboard/virtualkeyboardsettings.cpp#n70
I've created a task to make this clearer: https://bugreports.qt.io/browse/QTBUG-66172

Qt widgets project

When I looked at some of the GUI examples, I noticed some of the projects contains Forms folder and XXXX.ui files allowing user to modify the layout on the Design screen. But some of them don't have Forms folder and ui files but still have GUI to display.
So the GUI display on above latter cases are hand-coded and the other is using Designer. Is there a way to convert these two kind of projects from one to another?
Those .ui files are used by the User Interface Compiler[1] to generate some file named ui_formname.h that contains a class, Formname, inside the Ui namespace. So ultimately, everything resumes to C++ code
[1] http://qt-project.org/doc/qt-4.8/uic.html

Help context tagging Qt with slickedit

I am trying to get Slickedit working with the Qt framework so that I can navigate the codebase easily and because of the other features it provides. To context tag the library I go to Tools > Tag Files, then I right click on C/C++ to add tag file. I name it Qt.vtg and then select the following trees:
C:\Qt\2010.05\qt\src
C:\Qt\2010.05\qt\include
I get context tagging for something, but I can't get context tagging for some scenarios where I normally get it:
When I try to get the parameters for a second pointer, it shows nothing:
oldAddress = ui->addressText->
When I try to complete specific headers it also gives no help
#include <QtCore/ >
I don't know if I am missing a step for context tagging QT, or the additional steps for context tagging QT.
Ted.
You have to provide the include directories of QT for your project, either in your project's properties (Menu Project, Project properties, directories' tab), or in your compiler's properties (Menu Tools, Options, search for "Compiler properties"). This will enable your project to find the include files; the tag file alone doesn't really help, since you may have conflicting tags in the many tag files you could have, so the include files are necessary.
Make sure you have activated all the macros QT provides to your build system. It's been ten years since I used Qt, but IIRC there were several macro defines optionally specified on a compiler command line; make sure SlickEdit knows about them. (Menu Project, Project properties, compile/link tab).
If that's not sufficient, please give more details (where the definition is contained, settings for autocomplete, for context tagging, etc).

Resources