QIconView not emitting selectionChanged()

David Faure faure at kde.org
Tue Sep 12 22:39:49 BST 2006


On Monday 28 August 2006 15:54, Krzysztof Lichota wrote:
> Reposting to kde-core-devel, as it seems more appropriate list.
> 
> While testing my Cbar Konqueror extension I have noticed that multiple
> selection of items works in all Konqueror list views, but it doesn't
> work in icon views.
> 
> I have traced the problem down to QIconView. It does not emit
> selectionChanged() signal when selecting items by dragging selection box
> around them. It does when selecting by clicking on items.
> 
> So, is it a bug in Qt or intended behaviour? If a bug, can we work
> around it in KDE by providing right behaviour in KIconView?
> 
> I attach simple python app which illustrates the problem. It shows
> message box when selectionChanged() is emitted. It does not appear if
> the 2 items are selected by dragging selection around them.

Strange, because it works for me with a pure QIconView (no kde code).

Patch for qt3/examples/iconview/main.cpp
--- main.cpp    (revision 582808)
+++ main.cpp    (working copy)
@@ -41,6 +41,9 @@ public slots:
     void moved() {
         qDebug( "All selected items were moved to another widget" );
     }
+    void slotSelectionChanged() {
+        qDebug("slotSelectionChanged");
+    }

 protected:
     QWidget *view;
@@ -65,6 +68,7 @@ int main( int argc, char **argv )
     QObject::connect( &qiconview, SIGNAL( dropped( QDropEvent *, const QValueList<QIconDragItem> & ) ),
                      &listen_dnd, SLOT( dropped( QDropEvent * ) ) );
     QObject::connect( &qiconview, SIGNAL( moved() ), &listen_dnd, SLOT( moved() ) );
+    QObject::connect( &qiconview, SIGNAL( selectionChanged() ), &listen_dnd, SLOT( slotSelectionChanged() ) );

     a.setMainWidget( &qiconview );
     qiconview.show();

It's definitely emitted when dragging a selection around items.
So either
 - your version of Qt has a bug but it's fixed in mine (qt-copy, Qt-3.3.6, patches applied but hopefully they are more specific than that)
 - your test has a problem (e.g. the messagebox steals the focus away, or python loses the signal sometimes...)

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).




More information about the kde-core-devel mailing list