You are not logged in.
Pages: 1
How do I develop Qt applications in Java? I'm using KDEmod.
Offline
I'm guessing this.
Offline
I'm guessing this.
Ok so I installed QtJambi from AUR. I wrote this program:
class HelloWorld
{
public static void main(String args[])
{
QApplication.initialize(args);
QPushButton hello = new QPushButton("Hello World!");
hello.resize(120, 40);
hello.setWindowTitle("Hello World");
hello.show();
QApplication.exec();
}
}
Then I compile it:
┌─[armageddon @ dragonzden]
└─[~/Programming/Qt]> javac HelloWorld.java
HelloWorld.java:5: cannot find symbol
symbol : variable QApplication
location: class HelloWorld
QApplication.initialize(args);
^
HelloWorld.java:6: cannot find symbol
symbol : class QPushButton
location: class HelloWorld
QPushButton hello = new QPushButton("Hello World!");
^
HelloWorld.java:6: cannot find symbol
symbol : class QPushButton
location: class HelloWorld
QPushButton hello = new QPushButton("Hello World!");
^
HelloWorld.java:10: cannot find symbol
symbol : variable QApplication
location: class HelloWorld
QApplication.exec();
^
4 errors
How do I solve this problem ?
Offline
I am not playing with this at the moment (haven't programmed in Java in about a year, haha), but right off the bat, I notice you aren't importing anything, and I don't believe Java will all of the sudden do it by itself (from what I recall, it just imports java.lang by default - nothing else) so I believe you need to insert this at the top of your hello world program:
import com.trolltech.qt.gui.*;
Makes sense looking at the errors the compiler is spewing out, but this is only my educational guess from briefly and very briefly looking at this.
Last edited by Aprz (2009-09-10 11:00:45)
Offline
I am not playing with this at the moment (haven't programmed in Java in about a year, haha), but right off the bat, I notice you aren't importing anything, and I don't believe Java will all of the sudden do it by itself (from what I recall, it just imports java.lang by default - nothing else) so I believe you need to insert this at the top of your hello world program:
import com.trolltech.qt.gui.*;
Makes sense looking at the errors the compiler is spewing out, but this is only my educational guess from briefly and very briefly looking at this.
Thanks for the reply. I did as you said. Now I'm getting this:
┌─[armageddon @ dragonzden]
└─[~/Programming/Qt]> javac HelloWorld.java
HelloWorld.java:1: package com.trolltech.qt.gui does not exist
import com.trolltech.qt.gui.*;
^
HelloWorld.java:6: cannot find symbol
symbol : variable QApplication
location: class HelloWorld
QApplication.initialize(args);
^
HelloWorld.java:7: cannot find symbol
symbol : class QPushButton
location: class HelloWorld
QPushButton hello = new QPushButton("Hello World!");
^
HelloWorld.java:7: cannot find symbol
symbol : class QPushButton
location: class HelloWorld
QPushButton hello = new QPushButton("Hello World!");
^
HelloWorld.java:11: cannot find symbol
symbol : variable QApplication
location: class HelloWorld
QApplication.exec();
^
5 errors
Offline
maybe your qtjambi package installed the files in a non-standard path and now java isn't aware of it.
cheers
Barde
Offline
Just so you know, Jambi will not be worked on any more past Qt 4.5. It might not be a good choice for anything but fooling around, for that reason.
Offline
Thanks for that info. Just found out about that. It seems like using QtJambi will be a waste of time. I should just use Swing.
Offline
Or SWT
Offline
This probably won't be a popular response but if you want to use Qt then I'd suggest just using C++. It really won't be that hard to learn as you go since you know Java/OOP.
Offline
And no one forces you to do the """""real""""" (heavy quotes lol) programming in C++, you could just do the GUI in it.
Offline
And no one forces you to do the """""real""""" (heavy quotes lol) programming in C++, you could just do the GUI in it.
Very true.
Offline
Just so you know, Jambi will not be worked on any more past Qt 4.5. It might not be a good choice for anything but fooling around, for that reason.
Hey, I like fooling around. And I have the exact same problem as armageddon09 had. Now since I like Qt and the only programming language I know is a little bit of Java and I don't really wanna learn anything else (no matter how small the step to C++/C# would be), I would really like to be able to use QtJambi.
maybe your qtjambi package installed the files in a non-standard path and now java isn't aware of it.
How do I make Java (javac) aware of Jambi?
Offline
Pages: 1