Skip to content

QtWS: Early Bird Tickets Available!

  • 0 Votes
    6 Posts
    594 Views
    K

    Hello folks,

    I would like to give some feedback.
    Basically, it's quite simple: Only the interface class is passed as a ContextProperty, QML then automatically casts the class into the correct type.
    This also works very reliably.

    int main(int argc, char *argv[]) { QQmlApplicationEngine engine; IFoo *foo = new FooA; engine.rootContext()->setContextProperty("iFoo", foo); // in QML it is FooA }

    For differentiation, I return the class name in the interface class with the meta system. I have not found a function in QML that does this reliably (but I also use 5.9).

  • 0 Votes
    5 Posts
    2k Views
    G

    @fcarney Thanks a million. That was the problem.
    And thanks for the advice.

  • 0 Votes
    2 Posts
    668 Views
    SeDiS

    What is it that doesn't work? Any error messages?
    Perhaps you might want to have a look at Thomas Boutroues qqmlobjectlistmodel.h.

  • 0 Votes
    3 Posts
    7k Views
    E

    @hskoglund thank you so much!!!
    I import <QVarianList> and it solved my problem.

  • 0 Votes
    6 Posts
    5k Views
    SkroopaS

    @SGaist
    Thanks for you reply. The only way to create what I need - using Android functions directly and I must forgot about crossplatform for my app (if you want to use, for example, hardware acceleration or something).
    The code bellow is the main class (java, for use with QAndroidJniObject), that draws camera preview, using hardware:

    import org.qtproject.qt5.android.bindings.QtApplication; import org.qtproject.qt5.android.bindings.QtActivity; import android.hardware.Camera; import android.media.MediaCodec; import android.media.MediaCodecInfo; import android.media.MediaFormat; import android.media.MediaMuxer; import android.app.Notification; import android.app.NotificationManager; import android.content.Context; import android.graphics.SurfaceTexture; import android.view.TextureView.SurfaceTextureListener; import android.view.TextureView; import android.view.Gravity; import android.widget.FrameLayout; import android.os.Bundle; import java.io.File; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; public class CameraAndroid extends QtActivity implements SurfaceTextureListener { private static NotificationManager notificationManager; private static Notification.Builder notificationBuilder; private static CameraAndroid cameraAndroid; public CameraAndroid() { cameraAndroid = this; } private static MediaCodec mediaCodec; private static TextureView textureView; private static Camera camera; static int encWidth = 640, encHeight = 480; public static int start() { // Camera not started yet if(camera == null) { Camera.CameraInfo info = new Camera.CameraInfo(); // Set front facing camera by default int numCameras = Camera.getNumberOfCameras(); for (int i = 0; i < numCameras; i++) { Camera.getCameraInfo(i, info); if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { camera = Camera.open(i); break; } } if (camera == null) { camera = Camera.open(); } if (camera == null) return 9001; Camera.Parameters params = camera.getParameters(); Camera.Size cameraSize = params.getPreferredPreviewSizeForVideo(); for (Camera.Size size : params.getSupportedPreviewSizes()) { if (size.width == encWidth && size.height == encHeight) { params.setPreviewSize(encWidth, encHeight); break; } } // New camera preview size if (cameraSize != null) { params.setPreviewSize(cameraSize.width, cameraSize.height); } camera.setParameters(params); textureView.setLayoutParams(new FrameLayout.LayoutParams(camera.getParameters().getPreviewSize().width, camera.getParameters().getPreviewSize().height, Gravity.CENTER)); } return 0; } public static int stop() { if (camera != null) { camera.stopPreview(); camera.release(); camera = null; } return 0; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); textureView = new TextureView(this); textureView.setSurfaceTextureListener(this); setContentView(textureView); // <------------------------- Draws on all entire screen :(((( } @Override public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) { try { if(start() == 0) { camera.setPreviewTexture(surface); camera.startPreview(); } } catch (IOException ioe) { return 9002; } } @Override public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) { } @Override public void onSurfaceTextureUpdated(SurfaceTexture surface) {} @Override public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) { stop(); return true; } }

    But now, I can't see QML elements of my app! :(( Is it possible to draw QML elements over/above TextureView, change draw order or something? What I must to do?
    Many thanks!

  • 0 Votes
    5 Posts
    2k Views
    C

    @vishnu In a project called RBIMS, I created a text docuemt called RBIMS.qdocconf which contained the following text:

    include(compat.qdocconf) project = RBIMS outputdir += ./html headerdirs += . sourcedirs += . exampledirs = . imagedirs = ./images headers.fileextensions = "*.h *.ch *.h++ *.hh *.hpp *.hxx" sources.fileextensions = "*.cpp *.qdoc *.mm *.qml"

    I used the following command (executed from within my project folder) at the command line:

    ~/Qt/5.15.0/gcc_64/bin/qdoc /home/jim/Qt_Projects/RBIMS/RBIMS.qdocconf

    This produced an XML file in the html folder inside my project.

    <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE QDOCINDEX> <INDEX url="" title="RBIMS Reference Documentation" version="" project="RBIMS"> <namespace name="" status="active" access="public" module="rbims"> ... ... Code removed for brevity ... virtual="non" const="false" static="false" final="false" override="false" type="bool" signature="bool createDatabase()"/> <function name="database" fullname="database::database" href="database.html#database" status="active" access="public" location="database.h" filepath="/home/jim/Qt_Projects/RBIMS/database.h" lineno="36" documented="true" meta="constructor" virtual="non" const="false" static="false" final="false" override="false" type="" brief="Database::database test constructor doc parent" signature="database(int *parent)"> <parameter type="int *" name="parent" default="nullptr"/> </function>

    You can see (toward the end) that ....

    brief="Database::database test constructor doc parent"

    is created, which was a

    /*! * \brief database::database test constructor doc * \param parent */

    Qdoc comment in my code.