Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "widget.h"
- #include "ui_widget.h"
- #include <QDebug>
- #include <QRegExp>
- Widget::Widget(QWidget *parent) :
- QWidget(parent),
- ui(new Ui::Widget) {
- ui->setupUi(this);
- }
- Widget::~Widget()
- {
- delete ui;
- }
- void Widget::on_textBrowser_anchorClicked(const QUrl &url) {
- qDebug() << url.toString() << "clicked";
- }
- void Widget::on_pushButton_clicked() {
- auto text = ui->lineEdit->text();
- if (text.isEmpty()) {
- return;
- }
- QRegExp rx("((?:https?|ftp)://\\S+)", Qt::CaseInsensitive);
- text.replace(rx, "<a href=\"\\1\">\\1</a>");
- ui->textBrowser->append(text);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement