Unsolved Changing data in the core of the UI
-
Hi guys,
very new to using qt designer...
i have created a main window with my logo in the top left and four buttons running horizontally to the right.
How do you go about to change data in the bottom half of the screen to bring up relevant data according to the button you press...then change the screen when you click on a different button?
eg: i have clients then orders....so when i click on clients it must bring up options regarding clients...to be able to add,delete etc...then when i click on orders the same but for orders....obviously linking to one data base that can pull info and tie it together...
is this done at a programming level,or can designer handle this sort of thing?
any first steps appreciated
-
Hi
You should implement a slot to do the stuff when the button is clicked, e.g.:
connect(yourButton, SIGNAL(clicked()), this, SLOT(yourSlot))
To use "connect" like this, add Q_OBJECT to your header file.From this, everytime your button is pressed, it will trigger the slot "yourSlot".
'yourSlot' should be like this:
void classname::yourSlot()
{
//write your stuff here
qApp->processEvents();
}Note that if your stuff takes time to run, you should put it in another thread and then emit a signal from the thread to your GUI to display it.
Hope this helps.
-
@reezeus Why qApp->processEvents();?
-
qApp->processEvents(); enables to refresh the UI after modifications has been done by the code.
If you don't put it, your modification will actually be done, but the UI won't take it into account, so you will have the impression that nothing has been done.