コード例 #1
0
int
main(int argc, char** argv)
{
  //  Create the qt application object needed for the visualization.
  QApplication application(argc, argv);
  QObject::connect(&application, SIGNAL(lastWindowClosed()), &application, SLOT(quit()));

  //  The QtWindow class contains the main window needed for the visualization.
  QtWindow* window;

  //  Initialization of the coin 3D libraries which are needed for the visualization of the robot scenes.
  SoQt::init(window);
  SoDB::init();

  //  Create the TutorialPlanSystem class which contains our roblib plan system.
  boost::shared_ptr<TutorialPlanSystem> system(new TutorialPlanSystem());

  //  Create our main visualization window and pass our TutorialPlanSystem to the constructor.
  window = QtWindow::instance(system.get());

  //  Show the main visualization window to the user.
  window->show();

  //  Run the qt application.
  return application.exec();
}
コード例 #2
0
ファイル: QtMain.cpp プロジェクト: JamesLinus/pianobooster
int main(int argc, char *argv[])
{

    QApplication app(argc, argv);

     QString locale = QLocale::system().name();
     printf("locale = %s\n", qPrintable(locale));

    QString localeDirectory =
#ifdef Q_OS_WIN32
        QApplication::applicationDirPath() + "/translations/";
#endif
#ifdef Q_OS_LINUX
        QApplication::applicationDirPath() + "/../share/" + QSTR_APPNAME + "/translations/";
#endif
#ifdef Q_OS_DARWIN
        QApplication::applicationDirPath() + "/../Resources/translations/";
#endif


     QTranslator translator;
     if (!translator.load(QSTR_APPNAME + QString("_") + locale , localeDirectory))
        if (!translator.load(QSTR_APPNAME + QString("_") + locale, QApplication::applicationDirPath()  + "/translations/"))
            translator.load(QSTR_APPNAME + QString("_") + locale, QApplication::applicationDirPath());

     app.installTranslator(&translator);



    if (!QGLFormat::hasOpenGL()) {
        QMessageBox::information(0, QMessageBox::tr("OpenGL support"),
                 QMessageBox::tr("This system does not support OpenGL which is needed to run Piano Booster."));
        return -1;
    }

	QtWindow window;
    window.show();
	_window=&window;

    int value = app.exec();
    closeLogs();
    return value;
}
コード例 #3
0
ファイル: qt_dock_region.cpp プロジェクト: Aidanboneham/wgtf
void QtDockRegion::addView(IView& view)
{
	auto qMainWindow = qtWindow_.window();
	assert(qMainWindow != nullptr);

	auto findIt = dockWidgetMap_.find(&view);
	if (findIt != dockWidgetMap_.end())
	{
		// already added into the dockWidget
		return;
	}
	// IView will not control qWidget's life-cycle after this call.
	auto qtFramework = get<IQtFramework>();
	assert(qtFramework != nullptr);
	auto qWidget = qtFramework->toQWidget(view);
	if (qWidget == nullptr)
	{
		return;
	}
	auto centralWidget = qMainWindow->centralWidget();
	if (centralWidget != nullptr)
	{
		centralWidget->layout()->addWidget(qWidget);
	}
	qWidget->setSizePolicy(qDockWidget_.sizePolicy());
	qWidget->setMinimumSize(qDockWidget_.minimumSize());
	qWidget->setMaximumSize(qDockWidget_.maximumSize());
	qWidget->setSizeIncrement(qDockWidget_.sizeIncrement());
	qWidget->setBaseSize(qDockWidget_.baseSize());
	qWidget->resize(qWidget->baseSize());

	auto qDockWidget = new NGTDockWidget(&view);
	qDockWidget->setObjectName(view.id());
	IView* pView = &view;
	QtWindow* pWindow = &qtWindow_;
	QObject::connect(qDockWidget, &QDockWidget::visibilityChanged, [qDockWidget, pWindow](bool visible) {
		qDockWidget->visibilityChanged(visible);
		if (visible)
		{
			if (pWindow->isLoadingPreferences())
			{
				return;
			}
			QCoreApplication::postEvent(qDockWidget, new QEvent(QEvent::FocusIn));
		}

	});

	if (qtWindow_.isReady())
	{
		bool isOk = qMainWindow->restoreDockWidget(qDockWidget);
		if (!isOk)
		{
			setDefaultPreferenceForDockWidget(qDockWidget);
		}
		QmlView* qmlView = dynamic_cast<QmlView*>(pView);
		if (qmlView != nullptr)
		{
			if (qDockWidget->isVisible() && qDockWidget->getVisibility())
			{
				qmlView->setNeedsToLoad(true);
			}
		}
	}
	else
	{
		needToRestorePreference_.push_back(std::make_pair(qDockWidget, pView));
	}
	qDockWidget->setWidget(qWidget);

	std::string actionId("View.");
	actionId += view.title();

	auto action = qtFramework->createAction(actionId.c_str(), view.title(), "View", [pView, qDockWidget](IAction*) {
		qDockWidget->show();
		qDockWidget->raise();
		pView->focusInEvent();
	});
	auto application = get<IUIApplication>();
	assert(application != nullptr);
	application->addAction(*action);

	dockWidgetMap_[&view] = std::make_pair(std::unique_ptr<QDockWidget>(qDockWidget), std::move(action));
}