October 21, 2010

Dlang123 Dlang123
Lab Rat
2 posts

QUiLoader in QtScript won’t load a .ui file

 

I used QtScript Generator to generate the QT bindings.

Then I imported all the bindings into C++ and tried to make a quick sample program. What I am trying to do, is use QTDesigner to create a .ui file, and then use QtScript and QUiLoader to load the ui file in the script. I continuously get segfaults on the load portion.

Here is a simple version of the code.

  1.  function testThis(parent){
  2.          QMainWindow.call(this,parent);
  3.          this.loadUi();
  4.          }
  5.          
  6.       testThis.prototype = new QMainWindow();  
  7.       testThis.prototype.loadUi = function(){
  8.       var loader = new QUiLoader();
  9.       var file = new QFile('./test.ui');
  10.       var fileExists = file.exists();
  11.       if(fileExists){
  12.       var fileOpen = file.open(QIODevice.ReadOnly);
  13.       if(fileOpen){
  14.       var huh = loader.createWidget("QLabel",0, "test");
  15.       huh.show();
  16.       var ui = this.loader.load(this.file,this);
  17.       file.close();
  18.       }
  19.       }
  20.       }
  21.       var newWindow = new testThis();
  22.       QCoreApplication.exec();

the C++ side works fine, I am basically using the qs_eval that ships with the scripts to even try and test this. All of the opens and exists are true, so the QFile is there.

Just the ui=loader.load is where the problems are.. any help would be appreciated. It always throws a seg fault when it reaches this line of code.

Oh the huh label shows up just fine, so I know that the QUiLoader is at least working and creating widgets by name.

I am using Qt 4.7.

Oh and on a side note, I’ve tried it with the this. and I have tried it without them, some won’t work, but they all eventually give the same result.

1 reply

October 22, 2010

Dlang123 Dlang123
Lab Rat
2 posts

Funny thing.. I compiled 4.6.3 and redid the bindings from the lab using them.. this now works.

I still can’t get the bindings WebKit example to load, but this at least fixed my biggest issue.

 
  ‹‹ Should I report this bug?      Is it possible to set a background image to a widget? ››

You must log in to post a reply. Not a member yet? Register here!