DropShadow QML widget in Qt6 - qt

I have a problem:
I need to use DropShadow effect from QGraphicalEffects (which deleted in qt6) in my app.
How I can do it or replace it?

You can still import GraphicalEffects from the Qt5Compat module:
import Qt5Compat.GraphicalEffects
However you first have to install the Qt5Compat module from the Qt installer, which long term might not be what you want in new code as it is going to go away eventually.

Related

QtCreator: Custom QML Import Path states that the directory I specified is not a directory. The QML Type I am trying to import turns green

I hope the question is phrased properly, for I do not understand full what is happening in my application. I am currently trying to implement a custom version of QGroundControl and one of the things I am trying to do is replace the virtual joystick with a slider to control the yaw and pitch independently of a combined joystick via sliders.
I have created a custom qml file named "CustomHorizontalSlider.qml" and have placed it in this first image and have made sure that the file path is correct in Visual Studio Code: QtCreator Path:
I also have added the file to the custom.qrc and craeted a qmldir. Along with that I have used the updateqrc.py to make sure that the custom files are up to date: custom.qrc:
This is the error that I get when attempting to use that qml file now. Alongside here is the code if it is relevant: Error Message:
Import at the top:
Code changed to green:
Lastly, when I attempt to remove the import the module is no longer green.
Try importing as follows
import [path_to_dir] as MyControl
Example:
import "../../controls" as MyControl
And then you can use the alias to define elements (MyControl.[Name])
Example
MyControl.MyCustomButton
{
...
}

How do I import components into QtQuickDesigner?

I am trying to learn Qt version 6, and I'm at a point where my book has me importing QtQuick Controls. The book says to click on the "Imports tab" in the Library pane, and shows a screenshot containing the tab. (Virtually every web source I've been able to find says the same thing, with a similar screenshot.)
Unfortunately, my installation of Qt-Creator, version 4.15.1, installed with Qt 6, does not have an Imports tab on the library pane. This is what my Library pane looks like:
Yes, it appears that the controls have been imported, but I didn't do it through the UI, it happened during an experiment. What got the controls imported was:
I hand-edited the .ui.qml file to add the line
import QtQuick.Controls 2.4
I built the project
This resulted in the QtQuick controls appearing in the Library pane.
Surely this is not the normal way of importing controls, is it?
If I'm understanding correctly, you want Qt Design Studio to import modules for you from the UI.
Simply click here then:
Also, if your project was made with Qt6, there's no need to add the version in the import statement.
I hope I was of any help :)

Scene Builder - Custom Control Reuse

I've been at this problem trying to find workarounds for weeks now and I am starting to give up. I must be doing something fundamentally wrong. Anyway, this is my situation. I have previously made a neat little program using JavaFX but have now discovered Scene Builder and want to build it all again using this tool. The project includes several components that are frequently reused such as the one below. This is made up of a label, a slider, a text field and another custom component, an InfoIcon.
I have understood that the done thing is to import the custom component (the InfoIcon) as a .jar file into Scene Builder when building my SliderVariable as I call it. This works great and I can run a small demo of my SliderVariable from within Eclipse by creating a main method, a scene and making a SliderVariable in this scene. As mentioned this works great. Importing or Including the InfoIcon does not do what I want (I don't think) because then I cannot easily make changes to the InfoIcon (or its controller) and update my SliderVariable and then see the effects in the final product.
The problems arise when I want to take it one step further and in turn use my SliderVariable in Scene Builder. I do as with the InfoIcon. I export my slider variable to a non-executable jar and then import it into Scene Builder. Here Scene Builder complains that it cannot find any UI components and thus fails to import it. I have discovered that this is because when I export the SliderVariable as a jar it does not also package its dependencies meaning the InfoIcon doesn't get bundled with it and that the compiler cannot find this component as I try to use it.
I have tried to solve this with FatJar which I cannot get working (and it seems like it is not in use any more). I have tried Maven where I couldn't import the Maven project dependency of the InfoIcon in the FXML of the SliderVariable. Finally I have also tried simply not importing a jar but instead including the source code of InfoIcon in a separate package of SliderVariable but then I couldn't import it into my FXML. I am desperate. What do people normally do if they want to reuse custom components with their own controllers in Scene Builder? Is this even done? Should I just give up :'(?
This unwieldly post must be highly confusing but I do not know how to make it clearer. Any sort of response would be greatly appreciated and if you do not believe this forum is the right place to post something like this (which it probably isn't) please point me to someplace else where I am more welcome.
Many thanks.
EDIT 1: I have now added a folder in my project called Dependencies. In here I put a copy (not a reference to) my InfoIcon.jar.
I then add this .jar file to my Build Path and remove the old one. I then enter SceneBuilder and reimport the InfoIcon jar but this time from the Dependencies folder I just created. At this point the small project test I've made still runs fine. I then export as JAR file with the following settings and hit finish.
I then try to import it into Scene Builder and Scene Builder tells me it cannot find any UI components.
EDIT 2: Should I select these items?
Note that the jar file is in Dependencies but also in Referenced Libraries (which is not visible here). This type of selection makes it so that Scene Builder can find and Import the InfoIcon but not the SliderVariable.
When you export InfoIcon, you can simply select the packages and classes related to it in the Eclipse's package explorer (or other similar explorer views), and choose export.
Similarly, when you try to export SliderVariable control, you need to choose everything you have selected in InfoIcon, on top of other files that are needed by SliderVariable control itself.
If InfoIcon is imported into SliderVariable project as a JAR file, then you would need to manually select that JAR file during the export of SliderVariable.

How to import classes to create TextArea with line numbers in JavaFX

I want to create a TextArea in JavaFX with line numbers.
I think RichTextFX is want I am looking for but I don't know, how to import the classes in Netbeans correctly.
Following lines of code are from the XMLEditor.java demo:
import org.fxmisc.flowless.VirtualizedScrollPane;
import org.fxmisc.richtext.CodeArea;
import org.fxmisc.richtext.LineNumberFactory;
import org.fxmisc.richtext.StyleSpans;
import org.fxmisc.richtext.StyleSpansBuilder;
The last four import instructions are from project RichTextFX, and the first is from project Flowless. Is it sufficient to copy those 5 classes to my default package? Or should I download both projects, zip them to JARs and add them as a libraries?
In order to use RichTextFX, you need to add the whole library together with its dependencies. You can use a build tool with dependency management, such as maven, gradle or ant+ivy. Check the RichTextFX github page for more details.
If you want to do it manually, the easiest way is probably to download a "fat jar" from the RichTextFX releases page and add it to your project. It should include all the dependencies.

FLEX components: updating import statements to move the component into another folder

I've just imported a Flex component into my project.
I have a theory question about importing.
all the imports statements in the component source files started with "com.subFolder.etc", but I have preferred to move the component folders into "componentName" and to replace all import statements as "componentName.com.subFolder.etc"
Is this ok ? Everything works perfectly, but I was wondering if the method is correct.
thanks
You can put the components anywhere you like, however you want to organize them. People will site best practices and theory but if you know where everything is and you tell the compiler where they are:
import componentName.com.subFolder.componentToBeUsed;
Everything will compile and run just fine.
Usually you will see code and components broken up in a domain model.
So you'll have:
com.yoursite.views
com.yoursite.events
com.someothersite.renderers
Which correspond to:
/com/yoursite/views
/com/yoursite/events
Basically all of your code living in folders within /com/yoursite/
and:
/com/someothersite/renderers
being a custom renderer you imported from someothersite.com to use in your application.
In the end, for the compiler and the flash player I don't think it matters where you put things as long as your happy and understand it all...and of course 6 months from now when you come back to look at this code!
It's totally correct, yes.
Note that Flex Builder (if you're using it) can automatically replace your import statements/class name when you rename a directory or a .mxml/.as file.
I never tried moving a complete structure, though, but I would't be surprised if it worked too.

Resources