Layout Issue?



  • I am trying to layout my widgets but I seem to do something wrong. There is this scribbled text next to the word "Scenario". I am trying to layout this text below the text "Controls Data Consumptions Data Productions using a QGridLayout. For some reason, I don't get it right. Any suggestions in which direction I have to look for the problem. I don't see a way to put all the relevant code here as it is rather a lot...

    alt text


  • Moderators

    @ModelTech Just show us the creation code for the layout for the right pane, or even just the bottom of the right side pane.

    And my off the cuff guess is that you didn't get that text that is messed up in a layout at all.


  • Lifetime Qt Champion

    Hi,

    Looks like a work for QVBoxLayout and QHBoxLayout as well as QSplitter. QGridLayout might also be used.

    Do you have any particular problem ?



  • As said, it is rather complicated. The lower part of the QSplitter is a Widget that I called BehaviorEditor. The Layout of BehaviorEditor consists of a QVBoxLayout separating the top part with QLabel "Scenario" and the QLineEdit "BL". The bottom part is build up as a QHBoxLayout, of which here three Widgets are shown (it contains a forth which is set to invisible in this particular screenshot). Each of these three Widgets (called Collapsable) consists again of a QVBoxLayout, where the top contains the labels "Controls", "Data Consumptions" and "Data Productions" respectively. The problem is however with the bottom part of each of these three "Collapsable"s, which consists of a Widget with a QGridLayout. Somehow the QLabel Widgets in this QGridLayout-based Widget are not positioned at the right location, but at the LH top corner of BehaviorEditor.

    I have no clue where to start looking for the problem. What constructor code would be best to share?



  • I am already discovering that the problem is not in the constructors... I have to replace these bottom widgets of Collapsable and that seems to cause the problem somehow. So, how do you generally replace a Widget in some Layout by another Widget (of the same class)?


  • Moderators

    @ModelTech said in Layout Issue?:

    I am already discovering that the problem is not in the constructors... I have to replace these bottom widgets of Collapsable and that seems to cause the problem somehow. So, how do you generally replace a Widget in some Layout by another Widget (of the same class)?

    I don't think replacing them is the right approach. It still seems like you have a broken layout somewhere. This will be tough without seeing code, but I'll give it a shot.

    It looks like you have a broken layout which is why all the stuff scrunches together like that. From your description it is in the 4th widget. I'll just name it X since I don't know what it's called.

    Your widget Collapsable has the QVBoxLayout with the 3 labels and then below that it has the X widget. That X widget has it's own layout. So first things first, you can test that widget by itself and see if it's layout is broken. Simple test is:

    int main(int ac, char **av)
    {
       QApplication app(ac, av);
       X x;
       x->show();
       return app.exec();
    }
    

    If that widget looks ok then the problem will be in the vboxlayout of the whole Collapsable widget. If it doesn't then your layout issue is in the X widget. Show me the layout construction for that widget if that's the case.

    If not the place where you add the Collapsable's to a layout will be a good place to show some code.



  • Ok, I found a way to solve it for now. The problem was that not all widgets were added to a layout...


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.