Evgenii Legotckoi
Evgenii LegotckoiAug. 26, 2015, 9:15 a.m.

Qt/C++ - Lesson 010. QSplitter – how to add splitter?

Qualitative layout always increases application usability, and this is true for all kinds of applications, from desktop to mobile. One such interface elements, which can improve usability is QSplitter class, which is an object-type layout with a movable divider that separates the two areas in the application interface.

Project Structure for QSplitter

Project Structure for QSplitter Project structure completely unremarkable and a little interesting, since the main actions will be carried out in the designer, and QSplitter in mainwindow.cpp setting will produce a minimum.


Step by step with QSplitter

The first step - First add the two types of layout objects, which will be located elements of the interface

Adiing two layouts The second step - Choose a layout, both holding the Ctrl key and click on the button "Lay horizontally delimited", well, or "Lay vertically delimited", who despite what you need.

layout with QSplitter The third step - Stretch the area in which is located our QSplitter. This is necessary if the appearance of your QSplitter behaved not as you would have liked. To do this, select the parent widget, which is your QSplitter and click on the button "Lay on the grid." As a result, we obtain a result similar to the figure below.

Stretch the area with QSplitter The fourth step - we distribute multiple objects for clarity.

The fifth step - Correct the code to adjust the tension areas when you run the application and set the color separator.

#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    /* We set the parameters of areas stretching. 
     * Areas considered from left to right. 
     * The method setStretchFactor first set index field, and then her weight. 
     * Thus the first region set maximum weight and the second region is minimal.
     * */
    ui->splitter->setStretchFactor(0,1);
    ui->splitter->setStretchFactor(1,0);

    /* Also, just I want to show you how to choose the color separator. 
     * To do this we need to use a class QPallete, for which you choose the background color.
     * */
    QPalette p;
    p.setColor(QPalette::Background, Qt::red);
    /* And sets the palette QSplitter
     * */
    ui->splitter->setPalette(p);
}

MainWindow::~MainWindow()
{
    delete ui;
}

Result

We recommend hosting TIMEWEB
We recommend hosting TIMEWEB
Stable hosting, on which the social network EVILEG is located. For projects on Django we recommend VDS hosting.

Do you like it? Share on social networks!

Comments

Only authorized users can post comments.
Please, Log in or Sign up
AD

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:50points,
  • Rating points-4
m

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:80points,
  • Rating points4
m

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:20points,
  • Rating points-10
Last comments
i
innorwallNov. 15, 2024, 6:19 p.m.
Undocumented QMake - CONFIG += resources_big priligy for sale Most adjuvant drug therapies use substances that travel through the bloodstream, reaching cancer cells all over the body
i
innorwallNov. 15, 2024, 5:13 p.m.
PyQt5 - Lesson 003. QSystemTrayIcon - How to minimize application to tray Dowsett pointed out that, for all three receptor positive subgroups, the point estimate was to the left, suggesting a better performance for anastrozole than for tamoxifen, with no differences i…
i
innorwallNov. 15, 2024, 2:30 p.m.
Qt/C++ - Lesson 065. The correspondence of HTTP errors to server response errors in QNetworkAccessManager s Midsummer Classic in Kansas City priligy online pharmacy
i
innorwallNov. 15, 2024, 1:44 p.m.
Qt/C++ - Lesson 039. How to paint stroke in QSqlTableModel by value in the column? Many OPKs would advise users to start using the test strips around day 9 of your cycle, considering day 1 to be the first day of full menstrual flow buy priligy australia
i
innorwallNov. 15, 2024, 10:27 a.m.
Release of C++/Qt and QML application deployment utility CQtDeployer v1.4.0 (Binary Box) optionally substituted alkoxy, optionally substituted alkenyloxy, optionally substituted alkynyloxy, optionally substituted aryloxy, OCH, OC H, OC H, OC H, OC H, OC H, OC H, O C CH, OCH CH OH, O…
Now discuss on the forum
i
innorwallNov. 15, 2024, 6:38 p.m.
добавить qlineseries в функции Wallgren A, Baral E, Glas U Adjuvant breast cancer treatment with tamoxifen and combination chemotherapy in postmenopausal women priligy prescription 2 C averaged 106 48 mmol day duri…
t
tonypeachey1Nov. 15, 2024, 2:04 p.m.
google domain [url=https://google.com/]domain[/url] domain [http://www.example.com link title]
i
innorwallNov. 11, 2024, 6:55 p.m.
Всё ещё разбираюсь с кешем. priligy walgreens levitra dulcolax carbs The third ring was found to be made up of ultra relativistic electrons, which are also present in both the outer and inner rings
9
9AnonimOct. 25, 2024, 4:10 p.m.
Машина тьюринга // Начальное состояние 0 0, ,<,1 // Переход в состояние 1 при пустом символе 0,0,>,0 // Остаемся в состоянии 0, двигаясь вправо при встрече 0 0,1,>…

Follow us in social networks