Solved QT crashed when I try to do onglets->setCurrentIndex(0);
-
@f.lerdino
I have no idea whether this matters/causes your problem, but you seem to have:setCentralWidget(widget); ... setCentralWidget(onglets);
Is that right?
-
en fact i dont need the first one ... but nothing changed
-
Question, Is it possible to pass the *onglets as argument in the function?
-
Hi
you are doing that i ask in first post.You have
QTabWidget *onglets; in h file but new another so that is why you crash./****************************/
QWidget fenetre; // this ones DIES as soon as functions ends. not good.// 1 : Créer le QTabWidget
QTabWidget *onglets = new QTabWidget(&fenetre); THis one create a local variable,It is not the one from .H ( and it cant be used outside the function)
So that is why you crash.
-
@f.lerdino
Yep, exactly as @mrjj has just written above! -
@f.lerdino One more issue is you create a local QWidget on the stack in the constructor:
QWidget fenetre; QTabWidget *onglets = new QTabWidget(&fenetre); `` That means it will be destroyed when the constructor finishes.
-
Purely OOI: I don't use Qt Creator/C++, but in this case where there is a class member variable named
foo
and then a function local variable also namedfoo
is declared, does the Qt Creator "squiggle underline" the local variable warning that it "overrides the class variable", for the OP to notice? My PyCharm/Python IDE does do that.... -
@JonB
Not per default. Maybe with c-lang code model.
I wish it did. :) -
@mrjj
Upgrade to Python ;-) LMAO/ROFL -
@JonB
:)))
I would - if you give me visible scopes and remove that dreadful Self.
and what is up with ___Var to say its private :)
Joking aside, its really a nice editor. I assume the Pro version is even more
cool than the Community version.