def get_all_items(list_widget, as_string=True):
    """
    Gets all the items in a listWidget as a list

    :param list_widget: your QListWidget
    :param as_string: <bool> if set to true, will return the text of the item. If set to false will return the actual QListWidgetItem
    :return: items of your QListWidget
    """
    items = []

    if as_string is True:
        for item in [list_widget.item(i).text() for i in
                     range(list_widget.count())]:
            if item is not None:
                items.append(item)
    else:
        for i in range(list_widget.count()):
            items.append(list_widget.item(i))

    return items