Results 1 to 2 of 2

Thread: display informations of QDirModel on QDialog

  1. #1
    Join Date
    Mar 2008
    Posts
    21
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default display informations of QDirModel on QDialog

    hi
    i have a QTreeView with QDirModel,
    on right click on a QTreeView lines, i display a menu context :

    Qt Code:
    1. //slot
    2. void MyTreeView::showContextMenu(QModelIndex index, QPoint point)
    3. {
    4. QString fP = ( (QDirModel *)model() )->fileInfo( index ).absoluteFilePath ();
    5. myAction *propertyAction = new myAction(QIcon("../img/property.png"), tr("&Proprietes"), this, tr("Ctrl+P"));
    6. connect( propertyAction, SIGNAL( triggered() ), this->parent(), SLOT( showDialogInfo() ) );
    7. QMenu treeMenu;
    8. treeMenu.addAction(propertyAction);
    9. treeMenu.exec(point);
    10. }
    To copy to clipboard, switch view to plain text mode 
    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
    Qt Code:
    1. connect( propertyAction, SIGNAL( triggered() ), this->parent(), SLOT( showDialogInfo(fP) ) );
    To copy to clipboard, switch view to plain text mode 
    this is my class mainwindow

    Qt Code:
    1. class myMainWindow : public QMainWindow
    2. {
    3. Q_OBJECT
    4. public:
    5. myMainWindow( QWidget * parent = 0, Qt::WindowFlags flags = 0);
    6. ~myMainWindow();
    7. private:
    8. MyTreeView *localDir;
    9. QComboBox *homeDir;
    10. myDialog *dialog;
    11. private slots:
    12. void showDialogInfo();
    13. };
    14.  
    15. void myMainWindow::showDialogInfo()
    16. {
    17. dialog->show();
    18. }
    To copy to clipboard, switch view to plain text mode 
    how can i emit a signal like actionCliked(QString filePath) in
    Qt Code:
    1. void MyTreeView::showContextMenu(QModelIndex index, QPoint point)
    To copy to clipboard, switch view to plain text mode 
    ?
    can that help me ?


    thank you

    [edit]
    simply, my question is:
    how can i send information (fP) from MyTreeView::showContextMenu() to myMainWindow::showDialogInfo() ?
    [/edit]
    Last edited by hbill; 10th April 2008 at 21:24. Reason: MyTreeView

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: display informations of QDirModel on QDialog

    Hi, what's about
    Qt Code:
    1. if (treeMenu.exec(point) == propertyAction)
    2. this->parent()->showDialogInfo(fP);
    To copy to clipboard, switch view to plain text mode 
    in MyTreeView::showContextMenu.
    or even better
    Qt Code:
    1. if (treeMenu.exec(point) == propertyAction)
    2. emit mySignalShowDialogInfo(fP);
    To copy to clipboard, switch view to plain text mode 

    Lykurg

  3. The following user says thank you to Lykurg for this useful post:

    hbill (10th April 2008)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.