Programatically Layout



  • Dear All:

    I have an stupid question, I am trying to create a layout similar to the QCreator but I don't arrive to do it correctly. I think that for the Project and OpenDocument they use Docking but what I don't understand is how they do to create the Bar at the left size of the OpenDocument and Open Documents?

    If someone know how to create a similar layout programatically that will be great.

    All the best
    Ernesto


  • Lifetime Qt Champion

    Hi,

    You can grab the Qt Creator sources and get some inspiration from there


  • Moderators

    This is not the actual layout from Creator but it will give you similar results. You can then go on splitting stuff up. The important thing is that if you also use dock widgets you should disallow them to dock on the left.
    @
    auto everything = new QWidget();
    auto leftBar = new QWidget();
    auto leftWindowStack = new QSplitter(Qt::Vertical);
    auto rightWindowStack = new QWidget();

    auto everythingLayout = new QHBoxLayout();
    everythingLayout->setContentsMargins(0,0,0,0);
    everythingLayout->setSpacing(0);
    everything->setLayout(everythingLayout);
    setCentralWidget(everything);

    leftBar->setFixedWidth(70);
    everythingLayout->addWidget(leftBar);

    auto rightSideLayout = new QVBoxLayout();
    everythingLayout->addLayout(rightSideLayout);

    auto mainSplitter = new QSplitter(Qt::Horizontal);
    rightSideLayout->addWidget(mainSplitter);
    mainSplitter->addWidget(leftWindowStack);
    mainSplitter->addWidget(rightWindowStack);

    auto statusBar = new QStatusBar();
    statusBar->setFixedHeight(15);
    rightSideLayout->addWidget(statusBar);

    for(int i = 0 ; i < 3; ++i)
    {
    auto window = new QWidget();
    window->setStyleSheet("background: yellow");
    leftWindowStack->addWidget(window);
    }

    //the ugly colors are just to see where stuff is
    mainSplitter->setStyleSheet("background: cyan");
    leftBar->setStyleSheet("background: green");
    leftWindowStack->setStyleSheet("background: red");
    rightWindowStack->setStyleSheet("background: blue");
    @
    This is what it looks like. The red and cyan bars are movable splitter handles.
    !http://i296.photobucket.com/albums/mm188/crossblades666/Layout.jpg(QtCreator layout)!


Log in to reply
 

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