Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) Qt QTreeWidgetExample2

 

QTreeWidgetExample2 is an example of QTreeWidgetExample2.

 

 

 

 

 

 

Technical facts

 

Application type(s)

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: CppQTreeWidgetExample2.pro

 

QT       += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = CppQTreeWidgetExample2
TEMPLATE = app
SOURCES += main.cpp
HEADERS  +=
FORMS    +=

 

 

 

 

 

main.cpp

 

#include <QApplication>
#include <QTreeWidget>
#include <QTreeWidgetItem>

int main(int argc, char *argv[])
{
  QApplication a(argc, argv);
  QTreeWidget w;

  //Hide the header
  w.setHeaderHidden(true);

  //Add five items
  for (int i=0; i!=5; ++i)
  {
    QTreeWidgetItem * const item = new QTreeWidgetItem;
    item->setText(0,QString::number(i));
    w.addTopLevelItem(item);
  }

  //Let the row colors alternate
  w.setAlternatingRowColors(true);

  //Allow items to be drag and dropped inside of the widget
  w.setDragDropMode(QAbstractItemView::InternalMove);

  //Let the drag and drop be animated
  w.setAnimated(true);


  w.show();
  return a.exec();
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml