vitaR
18th March 2014, 21:41
Hi I'm making simple things on a QMainWindow to see how it works, but I once I click a button to do something, nothing seems to change in the main window.
I tried to use repaint() and update() funtions but nothing happens.
And by the way, can someone explain me the difference between repaint() and update()? I understand what means each word, but if I'll use repaint(), the window gonna show the changes too? or I have to use the update() function?
All right to the point, My Code:
void Window::labels(){
example = new QLabel();
example->setText("Ejemplo: ");
acep = new QPushButton();
acep->setText("Aceptar");
linea = new QLineEdit();
linea->resize(10,30);
connect(acep,SIGNAL(clicked()),linea,SLOT(modify() ));
layoutH = new QHBoxLayout();
layoutH->addSpacing(20);
layoutH->addWidget(example);
layoutH->addSpacing(10);
layoutH->addWidget(acep);
layoutH->addSpacing(20);
layoutH->addWidget(linea);
layoutH->addSpacing(20);
container = new QWidget();
container->setLayout(layoutH);
this->setCentralWidget(container);
}
void Window::modify(){
line = linea->text(); //QString line, QEditLine linea, I know have closely the same name, but Im just testing simple things to see how it works.
line.append('s'); //
linea->setText(line);
linea->repaint(); // I used update too, and with the Window too, but nothing happens
this->update();
}
I tried to append a s to the QLineEdit to see if changes it, tried to clear the text too, but nothing happens.
I tried to set the window title with the text given in the QLineEdit, but not working too.
I tried to use repaint() and update() funtions but nothing happens.
And by the way, can someone explain me the difference between repaint() and update()? I understand what means each word, but if I'll use repaint(), the window gonna show the changes too? or I have to use the update() function?
All right to the point, My Code:
void Window::labels(){
example = new QLabel();
example->setText("Ejemplo: ");
acep = new QPushButton();
acep->setText("Aceptar");
linea = new QLineEdit();
linea->resize(10,30);
connect(acep,SIGNAL(clicked()),linea,SLOT(modify() ));
layoutH = new QHBoxLayout();
layoutH->addSpacing(20);
layoutH->addWidget(example);
layoutH->addSpacing(10);
layoutH->addWidget(acep);
layoutH->addSpacing(20);
layoutH->addWidget(linea);
layoutH->addSpacing(20);
container = new QWidget();
container->setLayout(layoutH);
this->setCentralWidget(container);
}
void Window::modify(){
line = linea->text(); //QString line, QEditLine linea, I know have closely the same name, but Im just testing simple things to see how it works.
line.append('s'); //
linea->setText(line);
linea->repaint(); // I used update too, and with the Window too, but nothing happens
this->update();
}
I tried to append a s to the QLineEdit to see if changes it, tried to clear the text too, but nothing happens.
I tried to set the window title with the text given in the QLineEdit, but not working too.