"mais pour ça, il faudrait sortir un peu des sentiers trollesques et des leçons de rhétorique..."
Marketainge QT
Compared to other toolkits and frameworks, Qt Jambi’s paint system is easier and more intuitive
to use. For example, consider a component with some graphical contents and a print
button. Using Swing, the programmer must implement the Printable and ActionListener
interfaces and the following two functions to pop up a print dialog enabling the user to print
the contents:
public int print(Graphics g, PageFormat pf, int pi)
throws PrinterException {
if (pi >= 1)
return Printable.NO_SUCH_PAGE;
// perform drawing
return Printable.PAGE_EXISTS;
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() instanceof JButton) {
PrinterJob printJob = PrinterJob.getPrinterJob();
printJob.setPrintable(this);
if (printJob.printDialog()) {
try {
printJob.print();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
}
Using Qt Jambi, all the programmer has to do is to connect the print button’s clicked()
signal to a custom print() slot:
void print() {
QPrinter printer = new QPrinter();
QPainter painter = new QPainter();
QPrintDialog printDialog = new QPrintDialog(printer, this);
if (printDialog.exec()) {
painter.begin(printer);
// perform drawing
painter.end();
}
}
In addition, Qt Jambi’s text handling is based on native font support, providing access to
platform features like ClearType anti-aliasing on Windows and Mac OS X, and sub-pixel
anti-aliasing on X11ä. QPainter can even be used to generate PDF documents, without
requiring a third-party component.
Qt Jambi’s rendering pipeline co-exists with Java2Dä rendering, meaning that it is possible
to use Java2D for advanced imaging and Qt Jambi’s graphic system for painting widgets.
[^] # Re: toolkit graphique = troll ?
Posté par golum . En réponse à la dépêche Trolltech publie les avancées de Qt pour Java. Évalué à 2.
Marketainge QT