Create the custom completer popup to avoid the problem with the wrong height of the default popup
parent
994c6833bc
commit
9e405b69fa
@ -0,0 +1,28 @@
|
||||
#include "completerpopup.hpp"
|
||||
|
||||
CSVWidget::CompleterPopup::CompleterPopup(QWidget *parent)
|
||||
: QListView(parent)
|
||||
{
|
||||
setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||
setSelectionBehavior(QAbstractItemView::SelectRows);
|
||||
setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
}
|
||||
|
||||
int CSVWidget::CompleterPopup::sizeHintForRow(int row) const
|
||||
{
|
||||
if (model() == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (row < 0 || row >= model()->rowCount())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
ensurePolished();
|
||||
QModelIndex index = model()->index(row, modelColumn());
|
||||
QStyleOptionViewItem option = viewOptions();
|
||||
QAbstractItemDelegate *delegate = itemDelegate(index);
|
||||
return delegate->sizeHint(option, index).height();
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
#ifndef CSV_WIDGET_COMPLETERPOPUP_HPP
|
||||
#define CSV_WIDGET_COMPLETERPOPUP_HPP
|
||||
|
||||
#include <QListView>
|
||||
|
||||
namespace CSVWidget
|
||||
{
|
||||
class CompleterPopup : public QListView
|
||||
{
|
||||
public:
|
||||
CompleterPopup(QWidget *parent = 0);
|
||||
|
||||
virtual int sizeHintForRow(int row) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue