Hi
I have a strange issue where I need to get filepath and filename on a single click of the item in the qtreewidget
{
Q_OBJECT
public:
browserwindow
(QWidget* parent
= 0);
~browserwindow();
//functions
void populate();
public slots:
public:
};
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;
};
To copy to clipboard, switch view to plain text mode
#include "browsemodel.h"
browserwindow
::browserwindow(QWidget* parent
){
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);
}
QModelIndex browserwindow
::getDetails(const QModelIndex &index
) // to get details on the index on single click {
QString filename
= model
->fileName
(index
);
return model->index(0);
}
#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(getDetails(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);
}
To copy to clipboard, switch view to plain text mode
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
Bookmarks