Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] QListView: slot connected to clicked(const QModelIndex &) never gets called for the first item

[SOLVED] QListView: slot connected to clicked(const QModelIndex &) never gets called for the first item

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    smita30apr
    wrote on last edited by
    #1

    Hi,

    I have a custom widget in my QListView. The strange part is that the slot connected to the clicked() signal never gets called for the first item .

    My Delegate looks like this:

    @Characters_view_delegate::Characters_view_delegate(QWidget *parent)
    : QItemDelegate(parent)
    , m_item_widget(new Characters_details_widget(parent))
    {
    }@

    Characters_details_widget is my custom widget.

    Strange thing is if i remove the parent in "Characters_details_widget" like:

    @Characters_view_delegate::Characters_view_delegate(QWidget *parent)
    : QItemDelegate(parent)
    , m_item_widget(new Characters_details_widget())
    {
    }@

    My slots gets called for the first item.

    Please let me know what is going wrong here.

    Thanks :)

    1 Reply Last reply
    0
    • A Offline
      A Offline
      arsinte_andrei
      wrote on last edited by
      #2

      all I can think about is that is that it doesn't have a parent when firstly constructed and it may be possible to be constructed with the default parent witch is 0. have you tried to debug it line by line to see how the values are changing? try to set up a breaking point and see for yourself what are the values there on first call. then on the second call it may have a parent and is working fine.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        smita30apr
        wrote on last edited by
        #3

        I figured out the problem.

        since my custom widget is defined in the constructor, and I also use it in my delegate paint() to paint it as per the number of items, this widget constructed in the constructor overlaps what the painter paints and thus its not working for the first item.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          arsinte_andrei
          wrote on last edited by
          #4

          ok now that you have figured out what was wrong can you please mark this topic as [SOLVED] for other to know that. just edit your main post title

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved