kamlmish
20th December 2010, 05:27
Hi
I have a strange issue where I need to get filepath and filename on a single click of the item in the qtreewidget
class browserwindow: public QTreeWidget
{
Q_OBJECT
public:
browserwindow(QWidget* parent = 0);
~browserwindow();
//functions
void populate();
public slots:
QModelIndex getDetails(const QModelIndex& index);
public:
QDirModel* model;
QTreeView* tree;
QModelIndex index;
};
#include "browsemodel.h"
browserwindow::browserwindow(QWidget* parent)
:QTreeWidget(parent)
{
model = new QDirModel(this);
tree = new QTreeView(this);
populate();
}
browserwindow::~browserwindow()
{
delete tree;
delete model;
}
void browserwindow::populate()
{
tree->setModel(model);
tree->setRootIndex(model->index(QDir::homePath()));
tree->setWindowTitle("Browse for folder");
tree->resize(820, 7200);
connect(this,SIGNAL(clicked(QModelIndex)),SLOT(get Details(QModelIndex)),Qt::DirectConnection);
}
QModelIndex browserwindow::getDetails(const QModelIndex &index) // to get details on the index on single click
{
QString filename = model->fileName(index);
return model->index(0);
}
Issue is that I get a SIGSERV segmentation fault when I run the above code
my main objective is that , when a user clicks on the "browse" button(add_link_folder.png), the browser should open(browser.png)
when the user single clicks on any file in the browser, it should go back to the (add_link_folder.png) and the location and name shud display the filepath and filename respectivly
I have a strange issue where I need to get filepath and filename on a single click of the item in the qtreewidget
class browserwindow: public QTreeWidget
{
Q_OBJECT
public:
browserwindow(QWidget* parent = 0);
~browserwindow();
//functions
void populate();
public slots:
QModelIndex getDetails(const QModelIndex& index);
public:
QDirModel* model;
QTreeView* tree;
QModelIndex index;
};
#include "browsemodel.h"
browserwindow::browserwindow(QWidget* parent)
:QTreeWidget(parent)
{
model = new QDirModel(this);
tree = new QTreeView(this);
populate();
}
browserwindow::~browserwindow()
{
delete tree;
delete model;
}
void browserwindow::populate()
{
tree->setModel(model);
tree->setRootIndex(model->index(QDir::homePath()));
tree->setWindowTitle("Browse for folder");
tree->resize(820, 7200);
connect(this,SIGNAL(clicked(QModelIndex)),SLOT(get Details(QModelIndex)),Qt::DirectConnection);
}
QModelIndex browserwindow::getDetails(const QModelIndex &index) // to get details on the index on single click
{
QString filename = model->fileName(index);
return model->index(0);
}
Issue is that I get a SIGSERV segmentation fault when I run the above code
my main objective is that , when a user clicks on the "browse" button(add_link_folder.png), the browser should open(browser.png)
when the user single clicks on any file in the browser, it should go back to the (add_link_folder.png) and the location and name shud display the filepath and filename respectivly