For sending the index back to the main window I would suggest using a signal.
In the header for list add a signals section to the class declaration
signals:
void indexSelected(int index);
signals:
void indexSelected(int index);
To copy to clipboard, switch view to plain text mode
or any other name you'd like.
In on_listWidget_itemClicked() you emit the signal
emit indexSelected(start_index);
emit indexSelected(start_index);
To copy to clipboard, switch view to plain text mode
Make gui::set_index a slot by putting it into a slots section of the class, e.g.
private slots:
void set_index(int index);
private slots:
void set_index(int index);
To copy to clipboard, switch view to plain text mode
Then connect at the place where you create the secondary window
connect(mileage_list, SIGNAL(indexSelected(int)), this, SLOT(set_index(int)));
connect(mileage_list, SIGNAL(indexSelected(int)), this, SLOT(set_index(int)));
To copy to clipboard, switch view to plain text mode
As for closing the sub window when the main window closes: make it a QDialog subclass (instead of deriving from QWidget) and pass the main window as the dialog's parent
list *mileage_list = new list(this);
list *mileage_list = new list(this);
To copy to clipboard, switch view to plain text mode
Cheers,
_
Bookmarks