-
Notifications
You must be signed in to change notification settings - Fork 0
/
ranking.cpp
46 lines (37 loc) · 1.02 KB
/
ranking.cpp
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
42
43
44
45
46
#include "ranking.h"
#include "tabuleiro.h"
#include <QtGui>
#include <QtWidgets>
Ranking::Ranking(int pScore)
:QFrame()
{
texto = new QLabel();
nome = new QLineEdit();
ok = new QPushButton();
score = pScore;
texto->setText("Digite seu nome: ");
ok->setText("Salvar");
QObject::connect(ok, SIGNAL(clicked()), this, SLOT(salvar()));
layoutH1 = new QHBoxLayout();
layoutH2 = new QHBoxLayout();
layoutV = new QVBoxLayout();
layoutH1->addWidget(texto);
layoutH1->addWidget(nome);
layoutH2->addWidget(ok);
layoutH2->setAlignment(Qt::AlignRight);
layoutV->addLayout(layoutH1);
layoutV->addLayout(layoutH2);
this->setLayout(layoutV);
}
Ranking::~Ranking()
{
}
void Ranking::salvar(){
this->hide();
QFile file("listaDeScores.txt");
if(!file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text))
return;
QTextStream out(&file);
out << nome->text() <<","<< score <<"\n";
qDebug()<<"Funcionou!"<< nome->text() << "\n"<< score <<"\n";
}