-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwidget.cpp
More file actions
36 lines (29 loc) · 784 Bytes
/
widget.cpp
File metadata and controls
36 lines (29 loc) · 784 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
}
Widget::~Widget(){};
void Widget::on_Search_button_clicked()
{
ui->result_list->clear();
QString input_string = ui->string_for_edit->text();
QStringList words = input_string.split(' ', QString::SkipEmptyParts);
words.sort();
int i = 0;
int k = 1;
while (i != words.count()-1) {
if (words[i] == words[i+1])
k++;
else if (words[i] != words[i+1]) {
ui->result_list->append(QString("%1 - %2").arg(words[i]).arg(k));
k = 1;
}
i++;
}
i = words.count() - 1;
ui->result_list->append(QString("%1 - %2").arg(words[i]).arg(k));
}