error: no member named 'addWidget' in 'QFrame'
-
Hands-On GUI Programming with C++ and Qt5, Packt, Lee Zhi Eng ch 9 - camera (c) April 2018
F:\Qt-Projects\Webcam\mainwindow.cpp:44: error: no member named 'addWidget' in 'QFrame'
I am getting an error --- how to add Widget in the current Qt version????mainWindow.cpp
void MainWindow::connectCamera() { QList<QCameraInfo> cameras = QCameraInfo::availableCameras(); foreach (const QCameraInfo &cameraInfo, cameras) { qDebug() << cameraInfo.description() << ui->deviceSelection->currentText(); if (cameraInfo.description() == ui->deviceSelection->currentText()) { camera = new QCamera(cameraInfo); viewfinder = new QCameraViewfinder(this); camera->setViewfinder(viewfinder); ui->webcamLayout->addWidget(viewfinder); // line 44 connect(camera, SIGNAL(error(QCamera::Error)), this, SLOT(cameraError(QCamera::Error))); connected = true; ui->connectButton->setText("Disconnect"); camera->start(); return; } } }
-
Hi,
Based on the name, it should be a layout and not a QFrame.
-
Hi
From the code here
https://github.com/PacktPublishing/Hands-On-GUI-Programming-with-CPP-and-Qt5its a
QVBoxLayout *webcam about;
(and code just compiles)so maybe bug in book or something like that ?
-
Hi
That is super odd.
it really is included in the download
Did you move the files around or anything like that ?
I can see it says
'..\Chapter09\mainwindow.ui'
Like its relative to the pro file
However, the .PRO file saysFORMS +=
mainwindow.uiso I wondered if you moved the .pro file or anything ?
-
@lse123
Im not sure what you mean but if
the projects are in different folder, its not an issue that
they have same names.But you really didnt answer if you did anything to the files after download as they do compile fine here?
So if you are not using the project as it, please tell what you do.
-
@lse123 I can build Chapter09 without issues - but I only opened Chapter09 project. But I noticed that there is Webcam.pro.user after git clone - this should not be part of the repository!
Try to delete Webcam.pro.user file, delete build directory and rebuild. -
@lse123 said in error: no member named 'addWidget' in 'QFrame':
but stays on 0%
Do you use Qt Maintenance Tool?
-
I would try to change the mirror, you might be hitting a faulty one.
-
@lse123 There is this tool you can use to change the mirror: https://github.com/JKSH/QtSdkRepoChooser
-
@lse123
Hi
you can also download offline installer
https://www.qt.io/offline-installers
Its bigger up front download but the same things that gets installed.