int main(int argc, char *argv[]) { QApplication app(argc, argv); app.addLibraryPath("../../../../qsparql/plugins"); QSparqlConnectionOptions options; options.setHostName("dbpedia.org"); QSparqlConnection connection("QSPARQL_ENDPOINT", options); QWidget mainWidget; SparqlQueryText queryText(connection); QPushButton button(QLatin1String("Run Query")); QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(&button); layout->addWidget(&queryText); mainWidget.setLayout(layout); mainWidget.resize(600, 300); QObject::connect(&button, SIGNAL(clicked()), &queryText, SLOT(runQuery())); mainWidget.show(); app.exec(); return 0; }
ObjectIterator Connection::execQuery(const tchar* query) const { ASSERT(isOpen()); WCL::ComStr language(L"WQL"); WCL::ComStr queryText(query); long flags(WBEM_FLAG_RETURN_IMMEDIATELY | WBEM_FLAG_FORWARD_ONLY); IEnumWbemClassObjectPtr enumerator; // Execute it. HRESULT result = m_services->ExecQuery(language.Get(), queryText.Get(), flags, nullptr, AttachTo(enumerator)); if (FAILED(result)) throw Exception(result, m_services, TXT("Failed to execute a WMI query")); return ObjectIterator(enumerator, *this); }