Results 1 to 3 of 3

Thread: QTreeView expand signals

  1. #1
    Join Date
    May 2008
    Location
    Stavanger, Norway
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QTreeView expand signals

    Working with QTreeView I've run into a problem related to the expanded signal. It seems that the very first time I select a file in the directory structure, expanded emits three signals, that is, one related to the selected file itself, and two aditional which seems to be the equivalent of the unix . and ..

    This only happens the first time I select a file. If a directory is selected only one signal is emitted......
    Can expand be configured to emit one signal only?


    Thanks,
    Vidar

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTreeView expand signals

    Which exact version of Qt are you using? I can't reproduce the problem with Qt 4.4.0.
    J-P Nurmi

  3. #3
    Join Date
    May 2008
    Location
    Stavanger, Norway
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTreeView expand signals

    Hi,

    I'm using version 4.3.1. Included are some sourcecode for convenience:
    The undelined connect is the one who trigger the signal.

    QObject::connect(treeView, SIGNAL(expanded(QModelIndex)), this, SLOT(resizeColumn_tw()));
    QObject::connect(treeView, SIGNAL(expanded(QModelIndex)), this, SLOT(getDirName_fs(QModelIndex)));
    QObject::connect(treeView, SIGNAL(collapsed(QModelIndex)), this, SLOT(resizeColumn_tw()));
    QObject::connect(treeView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(resizeColumn_tw()));
    QObject::connect(treeView, SIGNAL(clicked(QModelIndex)), this, SLOT(openMd5File(QModelIndex)));

    QObject::connect(treeView_2, SIGNAL(expanded(QModelIndex)), this, SLOT(resizeColumn_tw2()));
    QObject::connect(treeView_2, SIGNAL(expanded(QModelIndex)), this, SLOT(finnOppdrag(QModelIndex)));
    QObject::connect(treeView_2, SIGNAL(collapsed(QModelIndex)), this, SLOT(resizeColumn_tw2()));
    QObject::connect(treeView_2, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(resizeColumn_tw2()));
    QObject::connect(treeView_2, SIGNAL(clicked(QModelIndex)), this, SLOT(finnOppdrag(QModelIndex)));

    QObject::connect(pushButton_2, SIGNAL(clicked()), this, SLOT(showAllFiles_tw()));
    QObject::connect(pushButton_2, SIGNAL(clicked()), this, SLOT(resizeColumn_tw()));
    QObject::connect(pushButton, SIGNAL(clicked()), this, SLOT(findFileNames()));
    QObject::connect(pushButton_lagre, SIGNAL(clicked()), this, SLOT(writeSettings()));
    QObject::connect(pushButton_avbryt, SIGNAL(clicked()), this, SLOT(restoreSettings()));

    QObject::connect(pushButton_hent, SIGNAL(clicked()), this, SLOT(getArchive()));
    QObject::connect(calendarWidget, SIGNAL(selectionChanged()), this, SLOT(setDate()));
    QObject::connect(lineEdit, SIGNAL(textChanged(QString)), this, SLOT(enableViewButton()));
    QObject::connect(radioButton, SIGNAL(toggled(bool)), this, SLOT(enableHentButton()));
    QObject::connect(radioButton_2, SIGNAL(toggled(bool)), this, SLOT(enableHentButton()));
    QObject::connect(pushButton_avbrytHent, SIGNAL(clicked()), this, SLOT(avbrytHent()));
    QObject::connect(pushButton_sok, SIGNAL(clicked()), this, SLOT(sokMd5()));
    QObject::connect(pushButton_hent_2, SIGNAL(clicked()), this, SLOT(archive()));


    Calling showAllFiles_tw function to restore the tree-view, actually make the problem reappear for the first file selected:

    /// Retrieve the original directory: /archive
    void Tarkiv::showAllFiles_tw()
    {
    model->setReadOnly(true);
    treeView->setModel(model);
    treeView->setRootIndex(model->index(lineEdit_katalog->text()));
    treeView->hideColumn(2);
    current_model = model;
    }

Similar Threads

  1. QTreeView repaint
    By graeme in forum Qt Programming
    Replies: 17
    Last Post: 13th March 2012, 13:27
  2. QTreeView help
    By bepaald in forum Qt Programming
    Replies: 1
    Last Post: 15th August 2007, 21:22
  3. QTreeView: Holding a line on screen
    By gri in forum Qt Programming
    Replies: 1
    Last Post: 7th August 2007, 11:42
  4. background image in QTreeView
    By momesana in forum Qt Programming
    Replies: 2
    Last Post: 11th January 2007, 06:25
  5. paint QTreeView item !!
    By mcenatie in forum Qt Programming
    Replies: 2
    Last Post: 19th March 2006, 14:24

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.