File indexing completed on 2025-02-16 13:11:55
0001 #include "ksqueezedtextlabel.h" 0002 #include <QApplication> 0003 #include <QVBoxLayout> 0004 #include <QWidget> 0005 0006 int main(int argc, char **argv) 0007 { 0008 QApplication::setApplicationName(QStringLiteral("test")); 0009 QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true); 0010 QApplication app(argc, argv); 0011 0012 QWidget *box = new QWidget(); 0013 QVBoxLayout *layout = new QVBoxLayout(box); 0014 0015 KSqueezedTextLabel *l1 = new KSqueezedTextLabel(QStringLiteral("This is a rather long string"), box); 0016 KSqueezedTextLabel *l2 = new KSqueezedTextLabel(QStringLiteral("This is another long string, selectable by mouse\nsdfsdfsfsf\nsdfsdfsdf\n"), box); 0017 l2->setTextElideMode(Qt::ElideRight); 0018 l2->setTextInteractionFlags(Qt::TextSelectableByMouse); 0019 KSqueezedTextLabel *urlLabel = new KSqueezedTextLabel(QStringLiteral("http://www.example.com/this/url/is/selectable/by/mouse"), box); 0020 urlLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); 0021 0022 layout->addWidget(l1); 0023 layout->addWidget(l2); 0024 layout->addWidget(urlLabel); 0025 layout->addWidget(new QLabel(QStringLiteral("This is a normal QLabel"), box)); 0026 0027 QLabel *selectableLabel = new QLabel(QStringLiteral("This is a normal QLabel, selectable by mouse"), box); 0028 selectableLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); 0029 0030 layout->addWidget(selectableLabel); 0031 0032 box->show(); 0033 0034 return app.exec(); 0035 }