Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class DLL_EXPORT QTreeWidgetWrap : public Napi::ObjectWrap<QTreeWidgetWrap> {
Napi::Value insertTopLevelItems(const Napi::CallbackInfo &info);
Napi::Value selectedItems(const Napi::CallbackInfo &info);
Napi::Value setColumnCount(const Napi::CallbackInfo &info);
Napi::Value setColumnWidth(const Napi::CallbackInfo &info);
Napi::Value setHeaderLabel(const Napi::CallbackInfo &info);
Napi::Value setHeaderLabels(const Napi::CallbackInfo &info);
Napi::Value setItemWidget(const Napi::CallbackInfo &info);
Expand Down
18 changes: 14 additions & 4 deletions src/cpp/lib/QtWidgets/QTreeWidget/qtreewidget_wrap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ Napi::Object QTreeWidgetWrap::init(Napi::Env env, Napi::Object exports) {
env, CLASSNAME,
{InstanceMethod("addTopLevelItem", &QTreeWidgetWrap::addTopLevelItem),
InstanceMethod("addTopLevelItems", &QTreeWidgetWrap::addTopLevelItems),
InstanceMethod("insertTopLevelItem",
&QTreeWidgetWrap::insertTopLevelItem),
InstanceMethod("insertTopLevelItems",
&QTreeWidgetWrap::insertTopLevelItems),
InstanceMethod("insertTopLevelItem",&QTreeWidgetWrap::insertTopLevelItem),
InstanceMethod("insertTopLevelItems", &QTreeWidgetWrap::insertTopLevelItems),
InstanceMethod("selectedItems", &QTreeWidgetWrap::selectedItems),
InstanceMethod("setColumnCount", &QTreeWidgetWrap::setColumnCount),
InstanceMethod("setColumnWidth", &QTreeWidgetWrap::setColumnWidth),
InstanceMethod("setHeaderLabel", &QTreeWidgetWrap::setHeaderLabel),
InstanceMethod("setHeaderLabels", &QTreeWidgetWrap::setHeaderLabels),
InstanceMethod("setItemWidget", &QTreeWidgetWrap::setItemWidget),
Expand Down Expand Up @@ -153,6 +152,17 @@ Napi::Value QTreeWidgetWrap::setColumnCount(const Napi::CallbackInfo& info) {
return env.Null();
}

Napi::Value QTreeWidgetWrap::setColumnWidth(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);

int columns = info[0].As<Napi::Number>().Int32Value();
int width = info[1].As<Napi::Number>().Int32Value();
this->instance->setColumnWidth(columns, width);

return env.Null();
}

Napi::Value QTreeWidgetWrap::setHeaderLabel(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Napi::HandleScope scope(env);
Expand Down
4 changes: 3 additions & 1 deletion src/demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import { DateFormat } from './lib/QtEnums';
const { QMainWindow, QTreeWidgetItem, QTreeWidget, QDate, ItemDataRole, QDateTime } = require('./index');

const win = new QMainWindow();
win.resize(500, 500);
const tree = new QTreeWidget();
tree.setSortingEnabled(true);
tree.setHeaderLabels(['Date', 'Time']);
tree.setHeaderLabels(['Date', 'Time', 'Test Column']);
tree.setColumnWidth(1, 15); //Sets the size of the selected column (index, size).

const dates = [
'11/22/1973 02:55:43 AM',
Expand Down
9 changes: 9 additions & 0 deletions src/lib/QtWidgets/QTreeWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ export class QTreeWidget extends QAbstractScrollArea<QTreeWidgetSignals> {
this.native.setColumnCount(columnCount);
}

/**
* Sets the width of column of this QTreeWidget.
* @param column The column index.
* @param width The size of the columns.
*/
setColumnWidth(column: number, width: number): void {
this.native.setColumnWidth(column, width);
}

/**
* Sets the header label.
* @param label The header label.
Expand Down
2 changes: 1 addition & 1 deletion website/docs/development/setting-up.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Supported versions: Ubuntu 17.10 and up
3. Make, GCC v7, pkg-config
4. Qt (_Optional_): Make sure you followed the setup instructions from [Qode][qode_setup]

On Ubuntu: `$ sudo apt-get install pkg-config build-essentials` should install everything except Qt5.
On Ubuntu: `$ sudo apt-get install pkg-config build-essential` should install everything except Qt5.

Note: If you are using your own version of Qt make sure to

Expand Down