Hi, A forum says:
"You need to change your QFile constructor argument QFile out(":/test.txt"); to a correct path that could be QFile out("./test.txt"); or QFile out("C:/test.txt");" This way I cannot read and write it at the same time. It does not read it in, as there is no resource path there. It can be that I use 2 QUILoaders: one for the :\test.txt resource path, because it reads it in. And a .\test.txt resource path, because it can write it. But 2 files cannot be open at the same time. Tamas 2015-04-14 9:42 GMT+02:00 Tamás Nagy <tamas.nagy....@gmail.com>: > Hi, > > Ok, I added the mainwindow.ui to a resource file, now it can be opened. > > With your solution it works and finds the tabs: > > if (!file.open(QIODevice::ReadOnly | QIODevice::Text)); > > But I also have to modify the GUI, so I have to set it ReadWrite: > > if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) > > With this I get "Unknown Error" for trying to open the file. > I checked the file: it is not read only. > > Tamas > > > 2015-04-13 18:48 GMT+02:00 Alejandro Exojo <s...@badopi.org>: >> El Monday 13 April 2015, Tamás Nagy escribió: >>> Hi, >>> >>> It was almost impossible, but it does not load the UI file: >>> >>> GuiParser::GuiParser(QTreeWidget *tree) >>> { >>> treeWidget = tree; >>> >>> QUiLoader uiLoader; >>> QFile file("mainwindow.ui"); // I also copied file to C: root >>> and wrote fix path here >>> // I also wrote here a file.open, but it does not help to change >>> it from unknown error to a better one >> >> I don't understand that sentence. Were you able to open the file with QFile >> and confirm that the application can read it? >> >>> QMessageBox msgBox0; >>> msgBox0.setText( file.errorString() ); // gives UNKNOWN ERROR >> >> Well, in this code, you didn't call file.open(). >> >> Try just this: >> >> QFile file("mainwindow.ui"); >> if (!file.open(QIODevice::ReadOnly | QIODevice::Text)); >> qWarning() << "Could not open the file" << file.errorString(); >> else >> qDebug() << file.readLine(50); >> >> Then just look at the output in the console, or the "output" panel in >> creator, >> or whatever you are using. If you see the warning, you have the explanation >> there. If you see garbage output instead of text, your file is not how it >> should be. If you see something like the UI file contents (<?xml >> version="1.0" >> encoding="UTF-8"?> for example), then the problem is in the code below. But >> at >> least let's confirm this first. >> >> -- >> Alex (a.k.a. suy) | GPG ID 0x0B8B0BC2 >> http://barnacity.net/ | http://disperso.net >> _______________________________________________ >> Interest mailing list >> Interest@qt-project.org >> http://lists.qt-project.org/mailman/listinfo/interest _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest