Camera as a background
-
Hello everyone,
I newly discovered QT Creator by joining a student club which purpose is to fly a plane that can lift alot of weight. Long story short, I setted up a camera already in the background of my GroundStation HUD and I want to add some Widget, that will be dynamic, over the Background Camera.
I kind of want it to look like that:
My problem is I am unable to set up a custom Widget on top of the Camera.
void MainWindow::paintEvent(QPaintEvent *event) { //create a QPainter and pass a pointer to the device. //A paint device can be a QWidget, a QPixmap or a QImage QPainter painter(this); //a simple line painter.setOpacity(1.0); painter.drawLine(1,1,100,100); //create a black pen that has solid line //and the width is 2. QPen myPen(Qt::black, 2, Qt::SolidLine); painter.setPen(myPen); painter.drawLine(2,2,100,100); //painter.setCompositionMode(QPainter::CompositionMode_DestinationOut); //draw a circle //The setRenderHint() call enables antialiasing, telling QPainter to use different //color intensities on the edges to reduce the visual distortion that normally //occurs when the edges of a shape are converted into pixels painter.setRenderHint(QPainter::Antialiasing, true); painter.setPen(QPen(Qt::black, 1, Qt::DashDotDotLine, Qt::SquareCap)); painter.setBrush(QBrush(Qt::black, Qt::NoBrush)); for(int i = 0; i < 10; i++) { painter.drawEllipse(i, i, 100, 100); } }
I am looking to understand how I could put an overlay over my current camera or use my camera as a background. I've look up on Google, but nothing correspond to my specific needs.
Thank you for your time.
-
Hi and welcome to devnet,
The easiest would likely to use QtQuick, it makes creating such animated stuff easier.
If you would like to stay with widgets then you should make your widget background transparent and manually position it over your QCameraViewFinder.
You might also want to consider the Graphics View framework which also provides classes more suited for this kind of GUI.
Hope it helps