#include <QVBoxLayout>
#include <QLineEdit>
#include <QTreeWidget>
#include <QLineEdit>
#include <QTreeWidget>
MyWidget
::MyWidget(QWidget *parent
){
setWindowFlags(Qt::Popup | Qt::FramelessWindowHint);
vBoxLayout->setContentsMargins(1, 1, 0, 0);
vBoxLayout->addWidget(mLineEdit);
item->setText(0, "The quick brown fox jumps over the lazy dog");
treeWidget->addTopLevelItem(item);
item2->setText(0, "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog");
treeWidget->addTopLevelItem(item2);
item3->setText(0, "The quick brown");
treeWidget->addTopLevelItem(item3);
treeWidget->setWindowFlags(Qt::Popup);
treeWidget->setFocusPolicy(Qt::NoFocus);
treeWidget->setMouseTracking(true);
treeWidget->setColumnCount(1);
treeWidget->setUniformRowHeights(true);
treeWidget->setRootIsDecorated(false);
treeWidget
->setEditTriggers
(QTreeWidget::NoEditTriggers);
treeWidget
->setSelectionBehavior
(QTreeWidget::SelectRows);
treeWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
treeWidget->header()->hide();
treeWidget->resizeColumnToContents(0);
mLineEdit->installEventFilter(this);
vBoxLayout->addWidget(treeWidget);
connect(mLineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(updateList(const QString&)));
show();
mLineEdit->setFocus();
setLayout(vBoxLayout);
layout
()->setSizeConstraint
(QLayout::SetFixedSize);
}
#include <QVBoxLayout>
#include <QLineEdit>
#include <QTreeWidget>
#include <QLineEdit>
#include <QTreeWidget>
MyWidget::MyWidget(QWidget *parent)
: QWidget(parent)
{
setWindowFlags(Qt::Popup | Qt::FramelessWindowHint);
QVBoxLayout *vBoxLayout = new QVBoxLayout(this);
vBoxLayout->setContentsMargins(1, 1, 0, 0);
QLineEdit *mLineEdit = new QLineEdit;
vBoxLayout->addWidget(mLineEdit);
QTreeWidget *treeWidget = new QTreeWidget;
QTreeWidgetItem *item = new QTreeWidgetItem();
item->setText(0, "The quick brown fox jumps over the lazy dog");
treeWidget->addTopLevelItem(item);
QTreeWidgetItem *item2 = new QTreeWidgetItem();
item2->setText(0, "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog");
treeWidget->addTopLevelItem(item2);
QTreeWidgetItem *item3 = new QTreeWidgetItem();
item3->setText(0, "The quick brown");
treeWidget->addTopLevelItem(item3);
treeWidget->setWindowFlags(Qt::Popup);
treeWidget->setFocusPolicy(Qt::NoFocus);
treeWidget->setMouseTracking(true);
treeWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
treeWidget->setColumnCount(1);
treeWidget->setUniformRowHeights(true);
treeWidget->setRootIsDecorated(false);
treeWidget->setEditTriggers(QTreeWidget::NoEditTriggers);
treeWidget->setSelectionBehavior(QTreeWidget::SelectRows);
treeWidget->setFrameStyle(QFrame::Box | QFrame::Plain);
treeWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
treeWidget->header()->hide();
treeWidget->resizeColumnToContents(0);
mLineEdit->installEventFilter(this);
vBoxLayout->addWidget(treeWidget);
connect(mLineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(updateList(const QString&)));
connect(treeWidget, SIGNAL(itemClicked( QTreeWidgetItem*, int)), SLOT(updateLineEdit(QTreeWidgetItem*, int)));
move(QCursor::pos());
show();
mLineEdit->setFocus();
setLayout(vBoxLayout);
layout()->setSizeConstraint(QLayout::SetFixedSize);
}
To copy to clipboard, switch view to plain text mode
Bookmarks