ui->addTab "index out of range" !?
-
What platform are you on ?
-
MinGW or Visual Studio ?
-
Then you already have a debugger. Just start your application in debug mode, make it crash and you'll have the stack trace.
-
Then you already have a debugger. Just start your application in debug mode, make it crash and you'll have the stack trace.
-
Silly question but are you starting the application as usual or are you starting it with the other button which means "debug the application" ?
-
Silly question but are you starting the application as usual or are you starting it with the other button which means "debug the application" ?
-
Silly question but are you starting the application as usual or are you starting it with the other button which means "debug the application" ?
@SGaist
UPDATE
Ok now I know, there are two points in my function, where the program crashes.
My function:GraphWidget *newGraphWidget = new GraphWidget(this); graphWidgets.append(newGraphWidget); QString name = "tab " + QString::number(tabCounter); qDebug() << ui->Graph->currentIndex(); //ui->Graph->addTab(newGraphWidget, "title"); // !? PROBLEM !? qDebug() << ui->Graph->currentIndex(); tabCounter += 1; QVBoxLayout *vBoxLayout = new QVBoxLayout(); vBoxLayout->setAlignment(Qt::AlignTop); QWidget *allNodesWidget = new QWidget(); allNodesWidget->setLayout(vBoxLayout); //ui->allNodes_scrollArea->setWidget( allNodesWidgets[ui->Graph->currentIndex()] ); // !? PROBLEM !? allNodesWidgets.append(allNodesWidget);The two lines where I commented !? PROBLEM !? are the two lines. If I uncomment one of these, the program crashes with the Index error. (UPDATE: the second one is because ui->Graph->currentIndex() is -1)
I have really no Idea what this means...
Help please! -
What is the initial value of tabCounter? What is the vector size?
-
allNodesWidgets[ui->Graph->currentIndex()]ui->Graph->currentIndex()is almost certainly out of bounds -
What is the initial value of tabCounter? What is the vector size?
@Vinod-Kuntoji
The initial value of TabCounter is 0.
The vector has no specific size, it gets bigger when I add new items... what exactely do you mean? -
@Vinod-Kuntoji
The initial value of TabCounter is 0.
The vector has no specific size, it gets bigger when I add new items... what exactely do you mean?@Niagarer when you add new tab it do not mean that current index will be changed
-
@Niagarer when you add new tab it do not mean that current index will be changed
@Paul-Busovikov
Yes...?
To get sure I wroteqDebug() << ui->Graph->currentIndex();before and after adding a new tab
-
To make it easier:
the lineui->Graph->addTab(new QWidget(this), "hello");does not work. Doesn't matter where I call it.