16,706
社区成员
发帖
与我相关
我的任务
分享
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
installLogcatMessageHandler("ebook");
EbkWidget ebkWidget;
QString file;// = "/data/app-lib/QtApp-debug/english.ebk";
file = QCoreApplication::applicationDirPath() + "/english.ebk";
qDebug((char *)file.toStdString().c_str());
ebkWidget.loadEbk((char *)file.toStdString().c_str());
ebkWidget.show();
return a.exec();
}
我知道这样给您添了很多麻烦,但实在没办法了,不好意思。谢谢!!!
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
const QString ebkpath = EBK_DIR;
QDir dir(ebkpath);
NameListModel namelist;
foreach (QFileInfo fileInfo, dir.entryInfoList(QDir::Files))
{
namelist.addname(FileInfo(fileInfo.fileName()));
}
qmlRegisterType<EbkWidget>("RegisterMyEbkType", 1, 0, "MyClassType");
QQmlApplicationEngine engine;
QQmlContext *ctx = engine.rootContext();
ctx->setContextProperty("ebkmodel", &namelist);
engine.load(QUrl(QStringLiteral("qrc:///main.qml")));