QtJambi won't construct a QApplication - Scala

545 Views Asked by At

I am impatient enough not to like reading books or tutorials on the stuff i want to learn. That said, i almost always will get the toolchains ready and start firing code off with whatever crazy idea gets on my head.

Scala piqued my interest today and i inmediately setup IDEA with the Scala plugin to get started... now, i got some knowledge about the syntax and why Scala has that much amount of Awesome-Sauce, so i decided to test it out with another technology i didn't know: QT, especially QtJambi. I imported the QtJambi dist into the IDEA project structure and wrote this snippet:

import com.trolltech.qt.gui._

class MyMainWindow extends QWidget {
  def showWindow = {
    setWindowTitle("Scala Jambi Test")

    resize(250, 250)
    move(300, 300)

    show()
  }
}

object MainApp extends QWidget() {
  def main(args: Array[String]) {
    QApplication.initialize(args)

    new MyMainWindow().showWindow

    QApplication.exec
  }
}

It compiles and runs but i get this on the console:

QWidget: Must construct a QApplication before a QPaintDevice

Any ideas on what i am doing wrong are appreciated.

I might add that the same code on a standard java project with the same libs does work.

1

There are 1 best solutions below

1
On

The problem is that MainApp is extending QWidget, i removed the extension and the thing worked all out of the blue. If anyone knows why please comment, i'd love to know why that went wrong.