Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: QApplication before a QWidget #202

Open
akuzminykh opened this issue Apr 29, 2020 · 3 comments
Open

Error: QApplication before a QWidget #202

akuzminykh opened this issue Apr 29, 2020 · 3 comments

Comments

@akuzminykh
Copy link

I've compiled the plug-in, made all dependencies (.dlls) available and imported it successfully into Maya. Sadly, when I open the plug-in from the menu Maya crushes. I've checked the dump file and the error does occur because of a null pointer. Then I've rebuilt the plug-in in debug mode and watched maya.exe at runtime with the Visual Studio debugger.

I've found the exact errors:

QWidget: Must construct a QApplication before a QWidget

and

QWidget: Cannot create a QWidget without QApplication

The file with the error is this:

#include "meshroomMaya/qt/MVGMainWidget.hpp"
#include "meshroomMaya/qt/QmlInstantCoding.hpp"
//#include "meshroomMaya/qt/QWheelArea.hpp"
#include "meshroomMaya/maya/MVGMayaUtil.hpp"
#include "meshroomMaya/qt/MVGCameraWrapper.hpp"
#include "meshroomMaya/qt/MVGCameraSetWrapper.hpp"
#include <QFocusEvent>
#include <QQuickWidget>
#include <QQmlEngine>
#include <QQmlContext>

namespace meshroomMaya
{

MVGMainWidget::MVGMainWidget(QWidget* parent)
    : QWidget(parent) // <- here
{
    setObjectName("mvgMainWidget");

    qmlRegisterType<MVGCameraWrapper>();
    qmlRegisterType<QObjectListModel>();
    qmlRegisterType<MVGCameraSetWrapper>();

    _view = new QQuickWidget(parent);

    _projectWrapper.loadExistingProject();
    QString importDirectory = QString(MVGMayaUtil::getModulePath().asChar()) + "/qml";

    // QtDesktop Components
    _view->engine()->addPluginPath(importDirectory);
    _view->engine()->addImportPath(importDirectory);

    // Expose Project to QML
    _view->rootContext()->setContextProperty("_project", &_projectWrapper);

    // Qml source
    const char* instantCoding = std::getenv("MESHROOMMAYA_USE_QMLINSTANTCODING");
    QString mainQml = importDirectory + "/mvg/main.qml";
    if(instantCoding)
    {
        QDir qmlFolder = QFileInfo(__FILE__).dir();
        qmlFolder.cd("qml");
        mainQml = QFileInfo(qmlFolder, "main.qml").absoluteFilePath();
        
        QmlInstantCoding* qic = new QmlInstantCoding(_view, true);
        qic->addFilesFromDirectory(qmlFolder.absolutePath(), true);
    }
    _view->setSource(QUrl::fromLocalFile(mainQml));
    _view->setResizeMode(QQuickWidget::SizeRootObjectToView);
}

MVGMainWidget::~MVGMainWidget()
{
    _projectWrapper.clearAndUnloadImageCache();
}

void MVGMainWidget::focusOutEvent(QFocusEvent* event)
{
    event->accept();
    _view->clearFocus();
}

QWidget* MVGMainWidget::getView() const
{
    return _view;
}

} // namespace

The error is at line 16. Could someone help me with that? What is the problem?


Specs:

  • Maya 2020
  • Visual Studio 2019
  • QT 5.12.5 (installed with vcpkg)

I've tried to compile the plug-in with Mayas verison of Qt as well, but when I set the cmake config up in cmake-gui I'm getting problems:

  • When I use the Qt files in the devkit for Maya, cmake tells me that it can't find the binaries, e.g. Qt5Core.dll. The devkit doesn't contain those.
  • When I use the Qt files in the installation folder of Maya, cmake tells me that the debug binaries are missing, e.g. Qt5Cored.dll. There are no debug binaries, neither in the installation folder nor the devkit.

The vcpkg installation of Qt has everything. Shouldn't the devkit contain all I need? Do I have to disable the referencing of the debug binaries somehow?

@akuzminykh akuzminykh mentioned this issue Apr 29, 2020
@fabiencastan
Copy link
Member

If I remember correctly, you need to merge the install of Maya and the devkit to get it correctly detected.

@fabiencastan
Copy link
Member

I have not yet tested it with Maya-2020.

@akuzminykh
Copy link
Author

It would be great if someone would check it with Maya 2020. I've just tried to use the custom Qt stuff (includes, libs) from Maya only and it's still not working. I've spent the last 3 weeks getting this plug-in to run. I'm done. I'm just done ..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants