Results 1 to 4 of 4

Thread: Connect button and pass QListView current index

  1. #1
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Connect button and pass QListView current index

    I want to connect a edit button to a editInfo() slot and pass the current selected index of a QListView as an argument.
    I dont think theres a way to pass a QListView index trough the clicked() signal. So I have to create a signal thats get triggered by the button being clicked, and then sends a signal to editInfo() passing the list's current index???? Maybe.. ?

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Connect button and pass QListView current index

    How about QAbstractItemView::clicked( const QModelIndex & index ) [signal] ?

    Also if your items are editable, the view might just provide an automatic editor. Why do u need extra handling of editing info ? Have a look at the delegates examples( under item views) in Qt Demos.

  3. #3
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Connect button and pass QListView current index

    The ListView has the names of XML files shown on a directory, so I want to select the files name, click a "edit" button and send the currentIndex(wich is a XML file name, say, options.xml) to a function for editing.

  4. #4
    Join Date
    Oct 2008
    Posts
    306
    Thanks
    6
    Thanked 9 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Connect button and pass QListView current index

    Ok, quite simple. Stupid me.
    Qt Code:
    1. dialog.editAlarm(ui->alarmList->currentIndex().data(0).toString());
    To copy to clipboard, switch view to plain text mode 
    Where "dialog" is my Dialog class, and editAlarm() is a public slot from Dialog.

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.