Solved ui->addTab "index out of range" !?
-
What is the initial value of tabCounter? What is the vector size?
-
This post is deleted! -
allNodesWidgets[ui->Graph->currentIndex()]
ui->Graph->currentIndex()
is almost certainly out of bounds -
@VRonin
Oh, yes you are right, thanks.
But it unfortunately does not solve teh actual problem :/ -
@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
-
@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.
-
@Niagarer
a QWidget is not really visible. (it paints nothing)
Try with other type -
@mrjj
Ok.
This also does not work:GraphWidget *newGraphWidget = new GraphWidget(this); //GraphWidget is a QGraphicsView ui->Graph->addTab(newGraphWidget, "hello");
-
@Niagarer
this works here
ui->tabWidget->addTab( new QPushButton("kkk") ,"tab" );
-
@mrjj
It doesn't work in my Program... xD
What the hell...
-
@Niagarer yes it doesn't
int index = 0; for (int i = 0; i < 10; ++i ) { index = ui->tabWidget->addTab( new QWidget, "title" ); qDebug() << index << " " << ui->tabWidget->currentIndex() ; }
0 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0
-
Hi
I assume you are doing other stuff in your app since it crashes.Just to be sure, your Qt is not sick.
Can you try test project
https://www.dropbox.com/s/tpyxmww5t98i4um/untitled39.zip?dl=0 -
@Paul-Busovikov
Oh yes, I see, I'm sorry. -
@mrjj
Yep, it works
Yes, I duplicated an old project. And now the MainWindow sould create a new tab in the tab widget called Graph with an object of my class GraphWidget (QGraphicsView). Nothing else (in the constructor). -
Ok, all good then (with your Qt) :)
It should be no different inserting a QGraphicsView subclass -
@mrjj
I'm not sure if I understood that correctly...
In the old project GraphWidget is just a normal Widget. Here it is a QGraphicsView. Where is the mattering difference? -
Its not. 100% the same.
class QGraphicsView : public QAbstractScrollArea
class QAbstractScrollArea : public QFrame
class QFrame : public QWidget -
@mrjj
Ok... So it is because of the QGraphicsView
And what could I do to fix that?