PDA

View Full Version : display informations of QDirModel on QDialog



hbill
10th April 2008, 20:21
hi
i have a QTreeView with QDirModel,
on right click on a QTreeView lines, i display a menu context :


//slot
void MyTreeView::showContextMenu(QModelIndex index, QPoint point)
{
QString fP = ( (QDirModel *)model() )->fileInfo( index ).absoluteFilePath ();
myAction *propertyAction = new myAction(QIcon("../img/property.png"), tr("&Proprietes"), this, tr("Ctrl+P"));
connect( propertyAction, SIGNAL( triggered() ), this->parent(), SLOT( showDialogInfo() ) );
QMenu treeMenu;
treeMenu.addAction(propertyAction);
treeMenu.exec(point);
}and i have a QDialog, i want display on this QDialog all information of directory or file selected (name, path, permission, owner, size .....) with the slot showDialogInfo();

can i do


connect( propertyAction, SIGNAL( triggered() ), this->parent(), SLOT( showDialogInfo(fP) ) );
this is my class mainwindow


class myMainWindow : public QMainWindow
{
Q_OBJECT
public:
myMainWindow( QWidget * parent = 0, Qt::WindowFlags flags = 0);
~myMainWindow();
private:
MyTreeView *localDir;
QComboBox *homeDir;
myDialog *dialog;
private slots:
void showDialogInfo();
};

void myMainWindow::showDialogInfo()
{
dialog->show();
}
how can i emit a signal like actionCliked(QString filePath) in

void MyTreeView::showContextMenu(QModelIndex index, QPoint point)?
can that help me ? :confused:


thank you :p


simply, my question is:
how can i send information (fP) from MyTreeView::showContextMenu() to myMainWindow::showDialogInfo() ?

Lykurg
10th April 2008, 21:36
Hi, what's about
if (treeMenu.exec(point) == propertyAction)
this->parent()->showDialogInfo(fP); in MyTreeView::showContextMenu.
or even better
if (treeMenu.exec(point) == propertyAction)
emit mySignalShowDialogInfo(fP);

Lykurg