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

From KDE TechBase
No edit summary
 
(Use Template:Proposed_deletion)
 
(10 intermediate revisions by 4 users not shown)
Line 1: Line 1:
'''main.cpp'''
{{Proposed_deletion}}
#include <kapplication.h>
 
#include <kaboutdata.h>
=Code it=
#include <kcmdlineargs.h>
 
#include <QTableWidget>
'''{{path|main.cpp}}'''
#include <QTreeWidget>
<syntaxhighlight lang="cpp-qt">
#include <QHeaderView>
#include <kapplication.h>
#include <kaboutdata.h>
int main (int argc, char *argv[])
#include <kcmdlineargs.h>
{
#include <QTableWidget>
  KAboutData aboutData( "test", "test",
#include <QTreeWidget>
      "1.0", "test", KAboutData::License_GPL,
#include <QHeaderView>
      "(c) 2007" );
 
  KCmdLineArgs::init( argc, argv, &aboutData );
int main (int argc, char *argv[])
  KApplication khello;
{
  KAboutData aboutData( "test", "test",
  QTreeWidget* mw=new QTreeWidget(0);
      "1.0", "test", KAboutData::License_GPL,
      "(c) 2007" );
  QStringList labels;
  KCmdLineArgs::init( argc, argv, &aboutData );
  mw->setColumnCount(2);
  KApplication khello;
  mw->setEditTriggers(QAbstractItemView::AllEditTriggers);
 
  QTreeWidgetItem* item=new QTreeWidgetItem(0);
  QTreeWidget* mw=new QTreeWidget(0);
  item->setText(1,"hi");
 
  item->setFlags(Qt::ItemIsEnabled);
  QStringList labels;
  mw->insertTopLevelItem(0,item);
  mw->setColumnCount(2);
  mw->show();
  mw->setEditTriggers(QAbstractItemView::AllEditTriggers);
  khello.exec();
  QTreeWidgetItem* item=new QTreeWidgetItem(0);
}
  item->setText(1,"hi");
'''CMakeLists.txt'''
  item->setFlags(Qt::ItemIsEnabled);
PROJECT( ktreewidget )
  mw->insertTopLevelItem(0,item);
FIND_PACKAGE(KDE4 REQUIRED)
  mw->show();
INCLUDE_DIRECTORIES( ${KDE4_INCLUDES} . )
  khello.exec();
}
</syntaxhighlight>
SET(ktreewidgetsources main.cpp )
'''{{path|CMakeLists.txt}}'''
<syntaxhighlight lang="text">
KDE4_ADD_EXECUTABLE(ktreewidget ${ktreewidgetsources} )
PROJECT( ktreewidget )
FIND_PACKAGE(KDE4 REQUIRED)
TARGET_LINK_LIBRARIES(ktreewidget ${KDE4_KDEUI_LIBS} ${KDE4_KPARTS_LIBS} )
INCLUDE_DIRECTORIES( ${KDE4_INCLUDES} . )
 
 
SET(ktreewidgetsources main.cpp )
 
KDE4_ADD_EXECUTABLE(ktreewidget ${ktreewidgetsources} )
 
TARGET_LINK_LIBRARIES(ktreewidget ${KDE4_KDEUI_LIBS} ${KDE4_KPARTS_LIBS} )
</syntaxhighlight>
 
=Kompile it=
 
cmake . -DCMAKE_INSTALL_PREFIX=$KDEDIR -DCMAKE_BUILD_TYPE=debugfull && make -j2 VERBOSE=1
 
=Run it=
 
./ktreewidget
 
[[Category:Proposed_deletion]]

Latest revision as of 12:22, 15 May 2019

 
Proposed for Deletion
This page has been proposed for deletion.

Code it

main.cpp

#include <kapplication.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <QTableWidget>
#include <QTreeWidget>
#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