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. Crashing when changing currentIndex of stackedWidget...
Forum Updated to NodeBB v4.3 + New Features

Crashing when changing currentIndex of stackedWidget...

Scheduled Pinned Locked Moved General and Desktop
19 Posts 4 Posters 9.3k Views 1 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.
  • L Offline
    L Offline
    Leon
    wrote on last edited by
    #7

    everything is valid..
    the momment i comment these lines

    @ /*
    createOptionsGroupBox();
    createButtonsLayout();
    mainLayout = new QVBoxLayout;
    mainLayout->addWidget(optionsGroupBox);
    mainLayout->addLayout(buttonsLayout);
    QWidget widget = new QWidget();
    widget->setLayout(mainLayout);
    setCentralWidget(widget);
    /@

    the

    @ ui->stackedWidget->setCurrentIndex(page_here);
    @

    will not crash the program

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DerManu
      wrote on last edited by
      #8

      Still don't see your problem with QtDesigner, really. I think you just didn't take the time to find out how it works. It'd pay off.
      Select the five top buttons and click the horizontal layout button. Select the six side buttons and click vertical layout. select the bottom button, label and combobox elements and click horizotal layout. Then select the table widget and the side-button-layout and click horizontal layout. Then select the main window and click vertical layout.
      Done, takes about 20 seconds.

      PS: What's the code of createButtonsLayout?

      1 Reply Last reply
      0
      • L Offline
        L Offline
        Leon
        wrote on last edited by
        #9

        [quote author="DerManu" date="1347713268"]Still don't see your problem with QtDesigner, really. I think you just didn't take the time to find out how it works. It'd pay off.
        Select the five top buttons and click the horizontal layout button. Select the six side buttons and click vertical layout. select the bottom button, label and combobox elements and click horizotal layout. Then select the table widget and the side-button-layout and click horizontal layout. Then select the main window and click vertical layout.
        Done, takes about 20 seconds.

        PS: What's the code of createButtonsLayout?[/quote]

        My friend DerManu thank you a lot, i played about 1 hour and managed to do something good. But with 2 questions, if you have the time to help me... So this is what i managed:

        !http://i.imgur.com/m1dnx.png(1)!
        !http://i.imgur.com/HR2Jf.png(2)!

        And the 2 questions..
        1st.. in the toolbar ( the 5 buttons ) as i have said they had some separators.. 1 width each one.. here you can see a screenshot that the separators dissapeared the moment a right clicked->layout->horizontally..

        !http://i.imgur.com/l3J2K.png(3)!

        2nd.. The groubox cannot work well with hidden objects.. for example u can see in the first screeenshot i attached here, the progressbar is not visible.. when i show it it appears normally
        !http://i.imgur.com/uizKE.png(4)!

        but when u hide it ( sorry for bad quality in this one )
        !http://i.imgur.com/j443P.png(5)!

        you see it leaves an empty space, where that empty space shouldn't be there.. :/
        the same is with start/stop buttons.. it's really ugly. .

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DerManu
          wrote on last edited by
          #10

          About the spacers: set an appropriate minimum width (1px).
          About the progress bar: Not sure what's going on there. I've tried it with a horizontal layout, and as soon as I set the visiblity of the progress bar to false, there is no space left but the other objects in the layout take up the space.

          1 Reply Last reply
          0
          • L Offline
            L Offline
            Leon
            wrote on last edited by
            #11

            About the separators: seemed like a qt bug, i reloaded the pixmaps and everything is ok..
            About the progressbar: well see how it is in the designer:

            !http://i.imgur.com/pgK1e.png(designer)!

            what do you suggest me about it?

            And one more.. as you can see in this screenshot :
            !http://i.imgur.com/8pJRu.png(screen)!

            the start converting and output format and combox is not in the middle of the listwidget.. in order to do that i should had the listwidget and these 3 widgets in a vertical layout.. but this can't happen because the listwidget is already in a layout with the buttons ( add,addfolder etc )... any ideas?

            Thank you, really thank you for answering until now.. You really helped me understand some things :)

            1 Reply Last reply
            0
            • D Offline
              D Offline
              DerManu
              wrote on last edited by
              #12

              To center the button/label/combobox under the view, use a QGridLayout with bottom right cell empty. Top left is the view, top right the vertically aligned buttons and bottom left the horizontally aligned button/label/combobox.

              Please elaborate on the progressbar issue. I don't see what's wrong with it.

              1 Reply Last reply
              0
              • L Offline
                L Offline
                Leon
                wrote on last edited by
                #13

                i am on another computer right now.. i will see what you said about the grid layout..

                for the progressbar look:

                On starting programm the windows looks like this
                !http://i.imgur.com/m1dnx.png(1)!

                the programm is a converter.. when you convert for example a video it shows a progressbar
                !http://i.imgur.com/uizKE.png(1)!

                and when finished it hides the progressbar
                !http://i.imgur.com/j443P.png(3)!

                but you can see that an ugly space created there.. why is that happening.. you can see my designer here do you have any suggestion?
                !http://i.imgur.com/l3J2K.png(4)!

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  DerManu
                  wrote on last edited by
                  #14

                  Is the topmost layout a QVBoxLayout (vertical layout) where the progressbar is one cell (the third from top, after the toolbuttons and the view-sidebuttons-layout)? If so, then it should actually work. I've created a similar situation for testing and there is no space left when hiding the progressbar.

                  1 Reply Last reply
                  0
                  • L Offline
                    L Offline
                    Leon
                    wrote on last edited by
                    #15

                    I am just dump :)
                    i wasn't hiding the progressbar but i was using QGraphicsOpacityEffect to set the opacity to 0 with a cool animation.. but when the opacity was 0 i was forgotting to call ->hide();

                    i have solved any of my previous problems, but i want to question one last thing and i am ready, look..
                    This is the window in the designer:
                    !http://i.imgur.com/lw1kT.png(1)!

                    And this is my mainwindows on action ( the arrows were added after the screenshot was taken ):
                    !http://i.imgur.com/aT50f.png(2)!

                    Do you see that empty space? I want the show errors buttons hidden , and visible only when there was an error at conversion of 1 file ( as said the programm is a converter )..

                    Well i can't hide the whole layout which inside there are a horizonal space and the show erros button because it says that u can't hide a horizontal spacer.. What the hek? What i am supposed to do for this?

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      DerManu
                      wrote on last edited by
                      #16

                      It doesn't work when just hiding the show-errors-button? Normally horizontal spacers shouldn't have a significant minimal height and thus the whole row should collapse horizontally to a few pixels (e.g. top+bottom margin of the layout).

                      Just a workaround idea: Why not place the button in the bottom right cell of the grid layout?

                      1 Reply Last reply
                      0
                      • L Offline
                        L Offline
                        Leon
                        wrote on last edited by
                        #17

                        Not it doesn't work when just hiding the show-errors-button..
                        and i cannot put it in the grid cause the grid is a stackedwidget.. i want the show erros buttons to be visible regardless the page of stacked widget..

                        my workaround idea is to set the height of the spacer to 0...
                        now it seems a little better :)

                        height=20
                        !http://i.imgur.com/ckofX.png(20)!

                        height=0
                        !http://i.imgur.com/LxW8z.png(0)!

                        1 Reply Last reply
                        0
                        • L Offline
                          L Offline
                          Leon
                          wrote on last edited by
                          #18

                          Xmm and how about adding a widget from code?
                          I mean i have all this widgets layouted in my designer.. what about if i have created a widget in my code and i wanted to add to the window?

                          yes there is a reason why i created it by code..

                          from a quick think i thought of making an empty stackedwidget ( that is layouted properly in the designer ), and then via code say something like ui->stackedwidget->addwidget(blabla).. but there isn't an addwidget function.. any ideas?

                          1 Reply Last reply
                          0
                          • A Offline
                            A Offline
                            andre
                            wrote on last edited by
                            #19

                            Leon, look into widget promotion for that. Insert the closest base class of your custom widget into your layout, and promote it to the real widget using the right-click menu -> promote... Alternatively: create a Qt Designer plugin for your custom widget. The latter is probably only worth-while for widgets that you expect to use regulary from designer.

                            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