Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. ui->addTab "index out of range" !?
Qt 6.11 is out! See what's new in the release blog

ui->addTab "index out of range" !?

Scheduled Pinned Locked Moved Solved General and Desktop
45 Posts 6 Posters 13.7k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    Can you provide a stack trace of your crash ?

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    NiagarerN 1 Reply Last reply
    1
    • SGaistS SGaist

      Hi,

      Can you provide a stack trace of your crash ?

      NiagarerN Offline
      NiagarerN Offline
      Niagarer
      wrote on last edited by
      #3

      @SGaist
      uuuhhm..
      I'm sorry, can you give me a link or sth. where I can see how...
      Unfortunately don't really know what you mean... (do you men an exeption output? )

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #4

        What platform are you on ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        NiagarerN 1 Reply Last reply
        0
        • SGaistS SGaist

          What platform are you on ?

          NiagarerN Offline
          NiagarerN Offline
          Niagarer
          wrote on last edited by
          #5

          @SGaist
          windows 10 x64

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #6

            MinGW or Visual Studio ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            NiagarerN 1 Reply Last reply
            0
            • SGaistS SGaist

              MinGW or Visual Studio ?

              NiagarerN Offline
              NiagarerN Offline
              Niagarer
              wrote on last edited by Niagarer
              #7

              @SGaist
              MinGW 32bit

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #8

                Then you already have a debugger. Just start your application in debug mode, make it crash and you'll have the stack trace.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                NiagarerN 1 Reply Last reply
                0
                • SGaistS SGaist

                  Then you already have a debugger. Just start your application in debug mode, make it crash and you'll have the stack trace.

                  NiagarerN Offline
                  NiagarerN Offline
                  Niagarer
                  wrote on last edited by
                  #9

                  @SGaist
                  There is nothing under Stack when I am debugging...
                  Are my settings wrong? I can't find anything wrong.
                  Also nothing under Breakpoints, Threads, Modules, Source Files, Snapshots and Registers.
                  Only the Debugger Log shows content

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    Silly question but are you starting the application as usual or are you starting it with the other button which means "debug the application" ?

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    NiagarerN 2 Replies Last reply
                    0
                    • SGaistS SGaist

                      Silly question but are you starting the application as usual or are you starting it with the other button which means "debug the application" ?

                      NiagarerN Offline
                      NiagarerN Offline
                      Niagarer
                      wrote on last edited by Niagarer
                      #11

                      @SGaist
                      No, I click Start Debugging
                      (but as I see now, there is Output in Modules tab when I am not closing the error message but it doesn't matter I think)

                      1 Reply Last reply
                      0
                      • SGaistS SGaist

                        Silly question but are you starting the application as usual or are you starting it with the other button which means "debug the application" ?

                        NiagarerN Offline
                        NiagarerN Offline
                        Niagarer
                        wrote on last edited by Niagarer
                        #12

                        @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!

                        1 Reply Last reply
                        0
                        • Vinod KuntojiV Offline
                          Vinod KuntojiV Offline
                          Vinod Kuntoji
                          wrote on last edited by
                          #13

                          @Niagarer ,

                          What is the initial value of tabCounter? What is the vector size?

                          C++, Qt, Qt Quick Developer,
                          PthinkS, Bangalore

                          NiagarerN 1 Reply Last reply
                          0
                          • VRoninV Offline
                            VRoninV Offline
                            VRonin
                            wrote on last edited by
                            #14
                            This post is deleted!
                            1 Reply Last reply
                            0
                            • VRoninV Offline
                              VRoninV Offline
                              VRonin
                              wrote on last edited by
                              #15

                              allNodesWidgets[ui->Graph->currentIndex()]

                              ui->Graph->currentIndex() is almost certainly out of bounds

                              NiagarerN 1 Reply Last reply
                              0
                              • VRoninV VRonin

                                allNodesWidgets[ui->Graph->currentIndex()]

                                ui->Graph->currentIndex() is almost certainly out of bounds

                                NiagarerN Offline
                                NiagarerN Offline
                                Niagarer
                                wrote on last edited by Niagarer
                                #16

                                @VRonin
                                Oh, yes you are right, thanks.
                                But it unfortunately does not solve teh actual problem :/

                                1 Reply Last reply
                                0
                                • Vinod KuntojiV Vinod Kuntoji

                                  @Niagarer ,

                                  What is the initial value of tabCounter? What is the vector size?

                                  NiagarerN Offline
                                  NiagarerN Offline
                                  Niagarer
                                  wrote on last edited by Niagarer
                                  #17

                                  @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?

                                  P 1 Reply Last reply
                                  0
                                  • NiagarerN Niagarer

                                    @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?

                                    P Offline
                                    P Offline
                                    Paul Busovikov
                                    wrote on last edited by
                                    #18

                                    @Niagarer when you add new tab it do not mean that current index will be changed

                                    NiagarerN 1 Reply Last reply
                                    0
                                    • P Paul Busovikov

                                      @Niagarer when you add new tab it do not mean that current index will be changed

                                      NiagarerN Offline
                                      NiagarerN Offline
                                      Niagarer
                                      wrote on last edited by Niagarer
                                      #19

                                      @Paul-Busovikov
                                      Yes...?
                                      To get sure I wrote

                                          qDebug() << ui->Graph->currentIndex();
                                      

                                      before and after adding a new tab

                                      1 Reply Last reply
                                      0
                                      • NiagarerN Offline
                                        NiagarerN Offline
                                        Niagarer
                                        wrote on last edited by
                                        #20

                                        To make it easier:
                                        the line

                                            ui->Graph->addTab(new QWidget(this), "hello");
                                        

                                        does not work. Doesn't matter where I call it.

                                        mrjjM P 2 Replies Last reply
                                        0
                                        • NiagarerN Niagarer

                                          To make it easier:
                                          the line

                                              ui->Graph->addTab(new QWidget(this), "hello");
                                          

                                          does not work. Doesn't matter where I call it.

                                          mrjjM Offline
                                          mrjjM Offline
                                          mrjj
                                          Lifetime Qt Champion
                                          wrote on last edited by
                                          #21

                                          @Niagarer
                                          a QWidget is not really visible. (it paints nothing)
                                          Try with other type

                                          NiagarerN 1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved