Important: Please read the Qt Code of Conduct -

Add custom QWidget to QListWidget

  • I created a list using QListWidget and would like to add my custom class derived from QWidget as entries into that list. The custom QWidget consists of four horizontally aligned elements; two labels, and two images, and some data to react to user input.

    I tried deriving my custom list entry from QListWidgetItem in order to add it to the QListWidget, but doing that I get an error when assigning my custom widget as the parent of any of its elements (candidate constructor not viable: no known conversion from 'ListEntry*' to 'QWidget *' for 1st argument).

    How would I go about creating a custom class composed of multiple widgets and adding it to a QListWidget?

Log in to reply