Make a custom signal for SecDialog, and add a member variable to keep track of what the user has ordered, something like:
{
// ... constructor, destructor, etc.
signals:
// ...
private:
}
class SecDialog : public QDialog
{
// ... constructor, destructor, etc.
signals:
void updateMenuItems( const QStringList & items );
// ...
private:
QStringList menuItems;
}
To copy to clipboard, switch view to plain text mode
The "menuItems" variable is to make it easier to retrieve the list of items the user has ordered. Otherwise, you would have to go into the list widget, retrieve each QListWidgetItem and then get the text for the item.
In each of your slots where the user has clicked a button to place an order, first push the item onto the string list, then add it to the widget:
void SecDialog::on_pushButton_pkt1_clicked()
{
menuItems.push_bask( paket1 );
ui->listWidget->addItem(paket1);
}
void SecDialog::on_pushButton_pkt1_clicked()
{
QString paket1 = "Paket 1";
menuItems.push_bask( paket1 );
ui->listWidget->addItem(paket1);
}
To copy to clipboard, switch view to plain text mode
When the user clicks the "OK" button, you will emit the updateMenuItems() signal and send the list of selected items:
void SecDialog::on_pushButton_OK_clicked()
{
emit updateMenuItems( menuItems );
}
void SecDialog::on_pushButton_OK_clicked()
{
emit updateMenuItems( menuItems );
}
To copy to clipboard, switch view to plain text mode
In the "display" dialog class, add a public slot to receive this signal:
public slots:
public slots:
void onUpdateMenuItems( const QStringList & items );
To copy to clipboard, switch view to plain text mode
void display
::onUpdateMenuItems( const QStringList & items
) {
ui->listwidget->clear();
ui->listwidget->addItems( items );
}
void display::onUpdateMenuItems( const QStringList & items )
{
ui->listwidget->clear();
ui->listwidget->addItems( items );
}
To copy to clipboard, switch view to plain text mode
In your SecDialog class, when you create the display dialog instance, you connect the signal from SecDialog to the slot in display.
Note that your code contains at least one bug: you should not create the display class in the on_pushbutton_display_clicked() slot. This code will result in a new display instance being created each time the button is clicked. You probably want only one of these, so create it in the SecDialog constructor and connect the signal and slot there.
There are several more things you have to think about
: When customer1 has placed the order, you need to have some way of clearing the list of items selected (and the list widget) so customer2 can start a new order. You also need to allow the customers to change their minds - if they order "Paket 1" but decide they don't really want it, how can they remove it from their order?
And when the chef finishes with the order, how can he erase the list of items? And how does the chef know which item goes to which customer?
I don't think a timer is a good idea. If the customer is entering their order then they change their mind and decide to remove some item, the timer might have already caused the item to be sent to the chef's list. Thus, the chef thinks he has to prepare something that the customer does not want. It is better to have a positive "commit" action (like clicking the OK button) that sends the final order to the chef.
Bookmarks