#include <QLineEdit>
class ElidedQLineEdit : public QLineEdit
{
Q_OBJECT
public:
explicit ElidedQLineEdit(QWidget *parent=0);
explicit ElidedQLineEdit(const QString &text, QWidget *parent=0);
void setText(const QString &text);
void setFullText(const QString &text);
void setTextLimitShrink(const QString &text, int width);
void setTextLimitExpand(const QString &text);
QString fullText() const;
protected:
void paintEvent(QPaintEvent *);
private:
void elideText();
private:
QString m_fullText;
};
ElidedQLineEdit::ElidedQLineEdit(QWidget *parent)
: QLineEdit(parent)
{
this->setMinimumWidth(0);
}
ElidedQLineEdit::ElidedQLineEdit(const QString &text, QWidget *parent)
: QLineEdit(text, parent), m_fullText(text)
{
this->setMinimumWidth(0);
}
void ElidedQLineEdit::setText(const QString &text)
Qt QLineEdit 根据拉伸宽度自动加省略点
最新推荐文章于 2024-06-06 16:24:46 发布