Development/Tutorials/Programming Tutorial KDE 4/Using QTableWidget: Difference between revisions
No edit summary |
Neverendingo (talk | contribs) m (Text replace - "</code>" to "</syntaxhighlight>") |
||
(6 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
{{Delete}} | |||
Use this as {{path|main.cpp}}: | |||
<syntaxhighlight lang="cpp-qt"> | |||
#include <kapplication.h> | |||
#include <kaboutdata.h> | |||
#include <kcmdlineargs.h> | |||
#include <QTableWidget> | |||
#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; | |||
QTableWidget* mw=new QTableWidget(0); | |||
QStringList labels; | |||
labels << "Greeting" << "Planet"; | |||
mw->setColumnCount(2); | |||
mw->setEditTriggers(QAbstractItemView::AllEditTriggers); | |||
mw->setHorizontalHeaderLabels(labels); | |||
mw->horizontalHeader()->setStretchLastSection(true); | |||
mw->insertRow(0); | |||
QTableWidgetItem* item=new QTableWidgetItem("Hello"); | |||
item->setFlags(Qt::ItemIsEnabled); | |||
item->setWhatsThis("You can change this task's comment, start time and end time."); | |||
mw->setItem(0,0,item); | |||
QTableWidgetItem* item2=new QTableWidgetItem("World"); | |||
mw->setItem(0,1,item2); | |||
mw->show(); | |||
khello.exec(); | |||
} | |||
</syntaxhighlight> | |||
Use this as CMakeLists.txt: | Use this as {{path|CMakeLists.txt}}: | ||
PROJECT( ktablewidget ) | PROJECT( ktablewidget ) | ||
FIND_PACKAGE(KDE4 REQUIRED) | FIND_PACKAGE(KDE4 REQUIRED) | ||
Line 45: | Line 49: | ||
TARGET_LINK_LIBRARIES(ktablewidget ${KDE4_KDEUI_LIBS} ${KDE4_KPARTS_LIBS} ) | TARGET_LINK_LIBRARIES(ktablewidget ${KDE4_KDEUI_LIBS} ${KDE4_KPARTS_LIBS} ) | ||
Compile it using | |||
cmakekde | |||
Call it using | |||
ktablewidget |
Revision as of 20:54, 29 June 2011
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.
Use this as main.cpp:
#include <kapplication.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <QTableWidget>
#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;
QTableWidget* mw=new QTableWidget(0);
QStringList labels;
labels << "Greeting" << "Planet";
mw->setColumnCount(2);
mw->setEditTriggers(QAbstractItemView::AllEditTriggers);
mw->setHorizontalHeaderLabels(labels);
mw->horizontalHeader()->setStretchLastSection(true);
mw->insertRow(0);
QTableWidgetItem* item=new QTableWidgetItem("Hello");
item->setFlags(Qt::ItemIsEnabled);
item->setWhatsThis("You can change this task's comment, start time and end time.");
mw->setItem(0,0,item);
QTableWidgetItem* item2=new QTableWidgetItem("World");
mw->setItem(0,1,item2);
mw->show();
khello.exec();
}
Use this as CMakeLists.txt:
PROJECT( ktablewidget ) FIND_PACKAGE(KDE4 REQUIRED) INCLUDE_DIRECTORIES( ${KDE4_INCLUDES} . ) SET(ktablewidgetsources main.cpp ) KDE4_ADD_EXECUTABLE(ktablewidget ${ktablewidgetsources} ) TARGET_LINK_LIBRARIES(ktablewidget ${KDE4_KDEUI_LIBS} ${KDE4_KPARTS_LIBS} )
Compile it using
cmakekde
Call it using
ktablewidget