PDA

View Full Version : Problem with UI showing



PoziomeQ
1st November 2012, 17:47
Hi. I have a small problem.
my code:


ka::ka(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::ka)
{
ui->setupUi(this);
QTextCodec::setCodecForTr(QTextCodec::codecForName ("UTF-8"));
QTextCodec::setCodecForCStrings(QTextCodec::codecF orName("UTF-8"));
QTextCodec::setCodecForLocale(QTextCodec::codecFor Name("UTF-8"));
go();

}


The function go(); is running before UI is showed but I dont want it like that.
The Ui should be show first, and then go(); should be run.
Could You help me?
Sorry for my bad english ;)
Thanks :)

Lykurg
1st November 2012, 19:03
call go() with a single shot timer or better reimp the showEvent and then start go().

PoziomeQ
1st November 2012, 19:40
i think time isnt problem here.

ka::ka(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::ka)
{
ui->setupUi(this);
QTextCodec::setCodecForTr(QTextCodec::codecForName ("UTF-8"));
QTextCodec::setCodecForCStrings(QTextCodec::codecF orName("UTF-8"));
QTextCodec::setCodecForLocale(QTextCodec::codecFor Name("UTF-8"));
QTimer::singleShot(1000, this, SLOT(quit()));
go();

}
it waits a few sec, do go(); function, a then shows ui

and i dont know how to use showEvent...




ka::ka(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::ka)
{
ui->setupUi(this);
QTextCodec::setCodecForTr(QTextCodec::codecForName ("UTF-8"));
QTextCodec::setCodecForCStrings(QTextCodec::codecF orName("UTF-8"));
QTextCodec::setCodecForLocale(QTextCodec::codecFor Name("UTF-8"));
QWidget::showEvent(this);
go();

}
I tried like that but it dosnt work.
thanks for helping... :)

Lykurg
2nd November 2012, 14:52
Make go() a slot and call that, not quit()...