-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
43 lines (35 loc) · 897 Bytes
/
Copy pathmainwindow.cpp
File metadata and controls
43 lines (35 loc) · 897 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
37
38
39
40
41
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "vkapi.h"
#include <QDebug>
#include <QUrlQuery>
#include <QJsonArray>
#include "user.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
vkApi = VkApi::getInstance();
qDebug()<<vkApi->getAuthUrl();
ui->web->setUrl(vkApi->getAuthUrl());
connect(ui->web,&QWebEngineView::urlChanged,this, &MainWindow::urlChange);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::urlChange(QUrl url)
{
url = url.toString().replace("#","?");
QUrlQuery *query = new QUrlQuery(url);
QString token = query->queryItemValue("access_token");
qDebug()<<token;
if(token != ""){
vkApi->setToken(token);
QList<int> s;
s.append(1);
vkApi->getUsers(s);
User *user = new User(vkApi, 0, this);
}
}