Difference between revisions of "Development/Tutorials/Programming Tutorial KDE 4/Using QTreeWidget"

Jump to: navigation, search
(This is not a tutorial and is nothing more than an overly specific code snippet)
m (Text replace - "<code cppqt>" to "<syntaxhighlight lang="cpp-qt">")
Line 4: Line 4:
  
 
'''{{path|main.cpp}}'''
 
'''{{path|main.cpp}}'''
<code cppqt>
+
<syntaxhighlight lang="cpp-qt">
 
#include <kapplication.h>
 
#include <kapplication.h>
 
#include <kaboutdata.h>
 
#include <kaboutdata.h>

Revision as of 20:30, 29 June 2011

Warning.png
Warning
This page has been nominated for deletion.

Reason: {{{1}}}

If you disagree with its deletion, remove the template and discuss it on its talk page.


Code it

main.cpp <syntaxhighlight lang="cpp-qt">

  1. include <kapplication.h>
  2. include <kaboutdata.h>
  3. include <kcmdlineargs.h>
  4. include <QTableWidget>
  5. include <QTreeWidget>
  6. include <QHeaderView>

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

 KAboutData aboutData( "test", "test",
     "1.0", "test", KAboutData::License_GPL,
     "(c) 2007" );
 KCmdLineArgs::init( argc, argv, &aboutData );
 KApplication khello;
 QTreeWidget* mw=new QTreeWidget(0);
 QStringList labels;
 mw->setColumnCount(2);
 mw->setEditTriggers(QAbstractItemView::AllEditTriggers);
 QTreeWidgetItem* item=new QTreeWidgetItem(0);
 item->setText(1,"hi");
 item->setFlags(Qt::ItemIsEnabled);
 mw->insertTopLevelItem(0,item);
 mw->show();
 khello.exec();

} CMakeLists.txt PROJECT( ktreewidget ) FIND_PACKAGE(KDE4 REQUIRED) INCLUDE_DIRECTORIES( ${KDE4_INCLUDES} . )


SET(ktreewidgetsources main.cpp )

KDE4_ADD_EXECUTABLE(ktreewidget ${ktreewidgetsources} )

TARGET_LINK_LIBRARIES(ktreewidget ${KDE4_KDEUI_LIBS} ${KDE4_KPARTS_LIBS} )

Kompile it

cmake . -DCMAKE_INSTALL_PREFIX=$KDEDIR -DCMAKE_BUILD_TYPE=debugfull && make -j2 VERBOSE=1

Run it

./ktreewidget

Content is available under Creative Commons License SA 4.0 unless otherwise noted.