Qt set iOS screen orientation - c++

Working on a cross platform app in Qt. I need to be able to force the screen orientation for a couple of pages. I've found a way to do this for Android, but I can't find anything for iOS.
Is there any way to force set the screen orientation in iOS?
Better yet, is there a single call that will set the screen orientation for any given mobile platform?
Thanks!

Have a look here:
https://doc.qt.io/qt-5/qml-qtquick-window-screen.html#orientation-attached-prop
You could write the Screen.orientation (or Screen.primaryOrientation) property into your own property and use the onChanged event handler to get a Signal, eg:
readonly property var screenOrientation: Screen.orientation
onScreenOrientationChanged: {
console.log("Orientation Changed!")
}

Related

what's the best approach to design this simple ReactNative AR app?

I'm trying to write a simple AR app in ReactNative, it should simply see 4 predefined markers and draw a rectangle as a boundary on the live preview of the camera, the thing is I'm trying to do the processing in C++ using opencv so as to have the logic of the app in one place accessible to both Android & IOS.
here's what I've been thinking
write the OS dependent code to open the camera and get permissions in (java/ObjC) & the C++ part to do processing on each frame.
call the C++ code (from within the native code) on each frame, and that should return lets say coordinates for the markers.
draw the rect if 4 markers found on the preview in native code (No idea how to achieve this so far but I think it will be native code).
expose that preview (the live preview with the drawn view) to ReactNative (Not sure about that or how to achieve it)
I've looked at the react native camera component but it doesn't provide access to frames & if that's even possible, I'm not sure if it would be a good idea to send frames over the bridge between JS & java/ObjC.
the problem is that I'm not sure of the performance or if that is even possible.
if you know of any ReactNative library that would be great.
Your steps seem sound. After processing the frame in C++, you will need to set the application properties RCTRootView.appProperties in iOS, and emit an event using RCTDeviceEventEmitter on Android. So, you will need an Objective-C wrapper for your C++ code on iOS and a Java wrapper on Android. In either case, you should be able to use the same React Native code for actually drawing the rectangle on top of the camera preview. You're right that the React Native camera component does not have an API for getting individual frames from the camera, so you'll need to write that code natively for each platform.

Convert View coordinates to Window Coordinates SFML

I have an application written using SFML with a menu bar up at the top and a small box that lets you move things around under it. I need to convert the coordinates that I have from the View that I am using in the box to window coordinates so I can check if they are inside the box or not. I know that convertcoords converts window coordinates to view coordinates but is there a way to do that in reverse?
With the latest SFML version (i.e. directly from GitHub or my Nightly Builds) you'll get the two functions mapPixelToCoords, formerly known as convertCoords, and mapCoordsToPixel, which is what you're looking for. Both functions are defined on the sf::RenderTarget and you can either let it use the view of the render target or provide an custom view.
...um, what? I'm not sure what you mean by 'View coordinates.' I think what you need is CWnd::MapWindowPoints, in which you can read about here.
mmm... I think there is no such function, you'll have to do it manually
http://en.sfml-dev.org/forums/index.php?topic=3257.0

QWidget / QWindow title bar: custom look, native feel (similar to Chrome)

I know how to make a QWidget (in Qt4 or Qt5) / QWindow (since Qt5) borderless, draw a custom title bar and manually implement mouse dragging to move the window on the screen by simply tracking the mouse position with some mouseMoveEvent and updating the window position.
However, this movement behaves different than the native one as implemented by the window manager. For example, moving the window near the screen's border can be interpreted as "fullscreen" or "split screen"; or windows snap to each other's borders, depending on the system / window manager. These things don't work if you implement the window movement like above.
Google Chrome / Chromium is only one example for an application which implements a custom window title bar and border, while still adapting to the native behavior of the window manager. I'm wondering whether Chrome implements these by itself (and detects the window manager and its configuration) or if there is some functionality in most window managers (clearly, this is still highly platform-dependent) for telling "start native window movement" and "stop native window movement" or similar.
Is something like that possible in Qt? If not, maybe using some other libraries like Qxt?
FYI: I'm mainly targeting Windows and Linux, where I see the difficulty that the user can have any window manager installed.
Based on attempting the same with Qt4 recently, I fear the answer is, you need to tune this per-platform / per-window-manager. I expect patches to QWindow to improve the behaviour in this area would be accepted, but I'm not aware of any standard hook to tell the OS/window-manager what you're trying to achieve.
Equally Qt should be not be 'getting in the way' of solving this, it's simply an area where it can't do anything to help you in a generic way.

Cocoa application with cocos2d-iphone?

I'd like to do this:
Create a Cocoa application with a couple NSButtons in it. Also, a "cocos2d-iphone" view running in the same window.
If I trigger the NSButtons, a function is called in the cocos2d-iphone view (not sure where, maybe in the currently running scene?).
Well, I managed to create a new project from the cocos2d-iphone for Mac template, made the window bigger than the cocos2d view, moved the cocos2d view, and added my NSButtons. Now, I am not very sure about how to make the connection I need.. =/
I suggest reading an Interface Builder tutorial. This one is using Quartz, it's not Cocos2D but close enough. Simply assume the Quartz view to be Cocos2D view while you go through the tutorial.
Note that Cocos2D/EAGLView has some issues with NSView objects. In particular you can't add NSView objects as subviews to the Cocos2D OpenGL view, they will simply not be displayed. This is a general problem of the OpenGL view on Mac, and there are solutions/workarounds for this but they unfortunately do not work with Cocos2D. So if you're planning to have NSView objects overlapping the Cocos2D view … well, you can try and if you can make it work, PLEASE let me know how! :)

How to create this animated arrow?

I have just installed a program on my pc and after that, an animated arrow is appeared on the screen showing me a new element on the bar:
How can I create this animated arrow ? What API do I have to use ?
It can be made with a window that has a custom shape. One of my colleagues documented how to do this in .NET here:
http://www.atalasoft.com/cs/blogs/jake/archive/2008/05/09/beauty-is-only-skin-deep-skinning-your-winforms-application.aspx
http://www.atalasoft.com/cs/blogs/jake/archive/2008/05/19/beauty-is-only-skin-deep-part-deux-if-it-looks-like-a-duck-it-might-be-a-winform.aspx
The same thing can be done in C++ by following the technique
I'm not aware that such a capability is exposed in an API. I expect the app draws it directly which it is of course perfectly entitled to do.