void MainWindow::on_treeView_clicked(const QModelIndex &index) { QUrl url; //QString qstrQML(CONFIGURATOR_API::getQML(index.internalPointer())); QString qstrFileName("/tmp/"); qstrFileName.append(CONFIGURATOR_API::getFileName(index.internalPointer())); qstrFileName.append(".qml"); qDebug() << qstrFileName; QFile qFile(qstrFileName.toLocal8Bit().data()); qDebug() << "this->getRegenerateQML() =" << this->getRegenerateQML() << " qFile.exists() = " << qFile.exists(); if (this->getRegenerateQML() == true || qFile.exists() == false) { QFile::remove(qstrFileName); if (qFile.open(QIODevice::WriteOnly | QIODevice::Truncate) == 0) { return; } QTextStream out(&qFile); out << CONFIGURATOR_API::getQML(index.internalPointer(), index.row()); } qFile.close(); //url.fromLocalFile(qstrFileName.toLocal8Bit().data()); m_pView->engine()->clearComponentCache(); m_pView->setSource(QUrl::fromLocalFile(qstrFileName.toLocal8Bit().data())); //m_pView->setSource(QUrl::fromLocalFile("/tmp/sasha.xsd.qml")); //m_pView->setSource(url); //m_pView->show(); /*m_pView = new QQuickView(); ApplicationData *pAppData = new ApplicationData(); m_pView->rootContext()->setContextProperty("ApplicationData", pAppData); TableDataModel *pTableDataModel = new TableDataModel[MAX_ARRAY_X]; for (int idx = 0; idx < MAX_ARRAY_X; idx++) { m_pView->rootContext()->setContextProperty(modelNames[idx], &(pTableDataModel[idx])); } m_pView->setSource(url);*/ //QWidget *container = QWidget::createWindowContainer(m_pView); //this->ui->verticalLayout->addWidget(container); }
int main( int argc, char **argv ) { QApplication a( argc, argv ); // parsing cmdline // syntax: [Collision 0-7], [IR 0-7], [Motor 0-1], [Inhibition], "Filename" if (argc > 1) { if (argc == 6){ argv++; QString qstrColl(argv[0]); argv++; QString qstrIR(argv[0]); argv++; QString qstrMotor(argv[0]); argv++; QString qstrInhibition(argv[0]); argv++; QString qstrFileName(argv[0]); int aiColl[8]; float afIR[8]; float afMotor[2]; int iInhibit; int ifound; int ii; QString qstrT; for (ii = 0; ii < 8; ii++){ qstrColl = qstrColl.simplifyWhiteSpace(); ifound = qstrColl.find ( " ", 0, false ) > 0 ? qstrColl.find ( " ", 0, false ): qstrColl.length(); qstrT = qstrColl.left(ifound + 1); qstrColl.remove(0, ifound + 1); aiColl[ii] = qstrT.toInt(); // printf("Coll: %i\n", qstrT.toInt()); } for (ii = 0; ii < 8; ii++){ qstrIR = qstrIR.simplifyWhiteSpace(); ifound = qstrIR.find ( " ", 0, false ) > 0 ? qstrIR.find ( " ", 0, false ): qstrIR.length(); qstrT = qstrIR.left(ifound + 1); qstrIR.remove(0, ifound + 1); afIR[ii] = qstrT.toInt(); // printf("%i, %i, IR: %i\n", ii, ifound, qstrT.toInt()); } for (ii = 0; ii < 2; ii++){ qstrMotor = qstrMotor.simplifyWhiteSpace(); ifound = qstrMotor.find ( " ", 0, false ) > 0 ? qstrMotor.find ( " ", 0, false ): qstrMotor.length(); qstrT = qstrMotor.left(ifound + 1); qstrMotor.remove(0, ifound + 1); afMotor[ii] = qstrT.toInt(); // printf("Motor: %i\n", qstrT.toInt()); } iInhibit = qstrInhibition.toInt(); ClsEPuckDisp clsEPuckDisp("EPuck Display"); clsEPuckDisp.setGeometry(0, 0, 250, 250); clsEPuckDisp.setCollision( aiColl ); clsEPuckDisp.setIR( afIR ); clsEPuckDisp.setMotor( afMotor ); clsEPuckDisp.setInhibition( iInhibit ); clsEPuckDisp.DrawStatus( ); clsEPuckDisp.setFileName ( qstrFileName ); clsEPuckDisp.saveGraph(); clsEPuckDisp.show(); a.setMainWidget( &clsEPuckDisp ); } else { printf("not enough or too many arguments\n"); exit(1); } } else { qtProtekData ProtekDlg; ProtekDlg.setGeometry( 160, 390, 280, //width 95 //height ); a.setMainWidget( &ProtekDlg ); ProtekDlg.show(); return a.exec(); } }