Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Is it possible to make the two widgets in a QSplitter of fixed size



  • I have a layout and QWidget and I have QSplitter with Vertical Orientation

    QVBoxLayout *container_layout = new QVBoxLayout;
    container_layout->addWidget(d_horSplitter);

    QWidget     *container =        new QWidget;
    container->setLayout(container_layout);
    d_verSplitter->setOrientation(Qt::Vertical);
    d_verSplitter->addWidget(container);
    d_verSplitter->addWidget(bottomWidget);
    

    I want to make container and bottomWidget of fixed size . Is it possible to make to widgets addWidgets in QSplitter as fixed size



  • Yes it is, as you probably already know by now, because adding the fixed size to your already existing widgets is a one-liner.


  • Lifetime Qt Champion

    Hi,

    Out of curiosity, why use a splitter if you want to fixe the size of your widgets ?



  • It is requirement from our marketing and could you let me know what is that one liner code . because I do not know yet


  • Lifetime Qt Champion

    So they basically want an unusable splitter ?

    You would already have that answer by searching fixed in the documentation.



  • @SGaist said:

    searching setWindowTitle(title);

    //creating two splitters
    
    d_horSplitter =   new QSplitter;
    d_verSplitter =   new QSplitter;
    
    
    /* creating the refresh button at the bottom*/
    QWidget *bottomWidget = new QWidget;
    /* to make the refresh button as of fixed size*/
    bottomWidget->setMaximumHeight(50);
    bottomWidget->setMinimumHeight(50);
    
    d_verSplitter->setOrientation(Qt::Vertical);
    d_verSplitter->addWidget(container);
    d_verSplitter->addWidget(bottomWidget);
    

    and it is working .

    <My question is that the correct way to do the same or is there a better to make the vertical splitter locked


  • Lifetime Qt Champion

    setFixedHeight would be cleaner.

    It's the only solution I know but like I wrote: having a locked splitter is counter intuitive and will make your users pretty angry.


Log in to reply