In my MainWindow i have a combobox and a select button. When the select button is clicked a new window is opened.
I want to be able to create a QString variable on the MainWindow that contains the text from the combobox, and pass that QString to the new window. The new window is going to perform different tasks, based on the contents of the QString (based on the selection of the combobox).
The following is my code so far...
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "testwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->cmboTestSelect->addItem("{Please Select a Test}");
ui->cmboTestSelect->addItem("Test 1");
ui->cmboTestSelect->addItem("Test 2");
ui->cmboTestSelect->addItem("Test 3");
ui->cmboTestSelect->addItem("Test 4");
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_btnTestSelect_clicked()
{
QString str_TestSelect = ui->cmboTestSelect->currentText(); //stores "Test Name" in string
hide();
Testwindow = new testwindow(this);
Testwindow->show();
}