How to get text input from user and set that text on a 3d object in Qt 3D?

Viewed 150

As shown in the picture below, which is taken from dynamic texture qt example, what I want to do is really simple, I want to get text input from the user and display it on a 3d object. I'm using C++ for the logic part of my application (just mentioning this because I don't know whether this animation is completely do-able in qml)

Qt dynamic texture example's image showing what I am trying to achieve

I am trying to create a credit card simulator, my 3d object would be the credit card and I would like to display the user's name and other such details, I would optionally like to add some logo to this credit card, if possible.

How would I go about doing this.

This is what my end 3d animation result should look like Credit card animation

1 Answers

do I understand correctly that you already have this textured credit card animation written in C++ and Qt3D?

So, I assume that you're using a QTextureMaterial for the credit card. This QTextureMaterial has a QTexture2D attached which in turn has a QTextureImage added to it.

I'd suggest you replace the current QTextureImage and subclass QPaintedTextureImage. QPaintedTextureImage allows you to draw the texture completely yourself, i.e. in the update function you first draw the (pre-loaded) standard credit card image using the painter and then on top you draw all the stuff you want to add. Since it's simply a QPainter you then use to paint you can paint anything on the credit card.

Related