Hi,
I am creating a Qt application on raspberry pi. I have a serise of checkboxes that if they are checked add their given number (1-25) to a QVector named Bank_1. I decided to display elements of the Vector in a text editor to make sure they are what I expected. They were not. When I display Bank_1[0] the result is anywhere from 24 to 495192 (or similar). Below is my code.
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
QVector<int> Bank_1(QVector<int>(6));
}
void MainWindow::on_add_Relay_pushButton_clicked()
{
if(ui->bank_Select_comboBox->currentText()=="Bank 1")
{
Bank_1[0] = 1;
}
//right now I am trying to get the number to display but am still getting odd results
void MainWindow::displayVector(QVector<int> bank)
{
int i = bank[0];
ui->relay_1_lineEdit->setText(s);
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QVector<int> Bank_1(QVector<int>(6));
}
void MainWindow::on_add_Relay_pushButton_clicked()
{
if(ui->bank_Select_comboBox->currentText()=="Bank 1")
{
Bank_1[0] = 1;
}
//right now I am trying to get the number to display but am still getting odd results
void MainWindow::displayVector(QVector<int> bank)
{
int i = bank[0];
QString s = QString::number(i);
ui->relay_1_lineEdit->setText(s);
}
To copy to clipboard, switch view to plain text mode
If you need to see the .h file I can add it. Any help or explanation would be greatly appreciated.
Bookmarks