Development/Tutorials/Programming Tutorial KDE 3/KHTML: Difference between revisions

From KDE TechBase
mNo edit summary
mNo edit summary
Line 23: Line 23:
</highlightSyntax>
</highlightSyntax>
It can be compiled like:
It can be compiled like:
  gcc -I/usr/lib/qt3/include -I/opt/kde3/include -L/opt/kde3/lib -lkdeui -lkhtml -o khtml khtml.cpp
  gcc -I/usr/lib/qt3/include -I/opt/kde3/include \
-L/opt/kde3/lib -lkdeui -lkhtml -o khtml khtml.cpp

Revision as of 12:00, 28 October 2006

For HTML parsing, you have 3 possibilities:

  • QXML
  • QDOM
  • khtml

Obviously, QXML and QDOM need xml-compliant html pages, and the least html pages are xml-compliant. So, this tutorial choses the khtml approach. Our first khtml-program does plain nothing: <highlightSyntax language="cpp">

  1. include <qstring.h>
  2. include <kapplication.h>
  3. include <kaboutdata.h>
  4. include <kmessagebox.h>
  5. include <kcmdlineargs.h>
  6. include <dom/html_document.h>

int main (int argc, char *argv[]) {

       KAboutData aboutData( "test", "test",
       "1.0", "test", KAboutData::License_GPL,
       "(c) 2006" );
       KCmdLineArgs::init( argc, argv, &aboutData );
       KApplication khello;
       DOM::HTMLDocument();

} </highlightSyntax> It can be compiled like:

gcc -I/usr/lib/qt3/include -I/opt/kde3/include \
-L/opt/kde3/lib -lkdeui -lkhtml -o khtml khtml.cpp