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. [SOLVED]Help on QSplitter
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]Help on QSplitter

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.6k 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.
  • M Offline
    M Offline
    M_31
    wrote on last edited by
    #1

    I have created my application using QSplitter to display different Widgets on my main Window.
    please refer the below window
    @


    | | | |
    | | | |
    | | | |
    | childsplit1 | child | child |
    | | splitter2 | splitter2 |
    | | | |
    | | | |
    | | | |
    |||________|

    @

    I want to display either Childsplitter2 or childsplitter3 at a time in my mainwindow and childsplitter1 will always display in my main window.
    I controlled the visibility property of childspiltter 2 & 3 by using the function setVisible( false or true) by pressing the corresponding button in toolbar and its working fine.

    First if i resize the childsplitter2 with my mouse, then i am not getting the childsplitter3 even with respective button press for childsplitter3 to visible.

    and its happening for childsplitter2 as well. if i resize the childSplitter3 .

    & i provided my code as well here..plz help me on this...

    @
    //mainwindow.h
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    #include <QtGui>
    #include <QMainWindow>
    #include "testdlg.h"
    #include "imagedlg.h"
    class MainWindow : public QMainWindow
    {
    Q_OBJECT
    public:

    void createToolBars();
    void createActions();
    void createMenus();
    void createStatusBar();
    explicit MainWindow(QWidget *parent = 0);
    QSplitter  *parentsplitter;
    QSplitter *childsplitter1;
    QSplitter *childsplitter2;
    QSplitter *childsplitter3;
    QTableView *tableview ;
    TestDlg *tstdlg;
    ImageDlg *imgdlg;
    QTextEdit *textedit;
    QTextEdit *textedit1;
     QList <int> lst;
     QList <int> zerosize;
    

    signals:

    public slots:

    void mainView();
    void thumbView();
    void questPolling();
    void showSessionEvent();
    

    private:
    QToolBar *controlToolBar;
    QAction *mainViewAct;
    QAction *thumbViewAct;
    QAction *questPollingAct;
    QAction *showSessionEventAct;

    };

    #endif // MAINWINDOW_H
    //mainwindow.cpp
    #include "mainwindow.h"
    #include <QtGui>

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent)
    {

        parentsplitter= new QSplitter;
        parentsplitter->setOrientation(Qt::Horizontal);
    
        childsplitter1 = new QSplitter(parentsplitter);
        childsplitter1->setOrientation(Qt::Vertical);
        textedit = new QTextEdit(childsplitter1);
        tableview = new QTableView(childsplitter1);
        childsplitter1->addWidget(tableview);
        childsplitter1->addWidget(textedit);
    
        childsplitter2 = new QSplitter(parentsplitter);
        childsplitter2->setOrientation(Qt::Horizontal);
        childsplitter2->addWidget(new TestDlg);
    
    
        childsplitter3 = new QSplitter(parentsplitter);
        childsplitter3->setOrientation(Qt::Horizontal);
        childsplitter3->addWidget(new ImageDlg);
    
    
        parentsplitter->addWidget(childsplitter1);
        parentsplitter->addWidget(childsplitter2);
        parentsplitter->addWidget(childsplitter3);
    
    
    
        //childsplitter2->setVisible(false);
        // childsplitter3->setVisible(false);
         createActions();
         createToolBars();
         setIconSize(QSize(60,70));
          setWindowFlags(Qt::Widget);
          setWindowTitle("main Window");
    
        setCentralWidget(parentsplitter);
        setWindowState(Qt::WindowMaximized);
    

    }
    void MainWindow::createToolBars()
    {
    controlToolBar = addToolBar(tr("Controls"));
    addToolBar(Qt::RightToolBarArea,controlToolBar);
    controlToolBar->setMovable(false);
    controlToolBar->setAutoFillBackground(true);

    controlToolBar->addAction(mainViewAct);
    controlToolBar->addAction(thumbViewAct);
    controlToolBar->addAction(questPollingAct);
    controlToolBar->addAction(showSessionEventAct);
    

    }
    void MainWindow::createActions()
    {
    mainViewAct = new QAction(QIcon(":/images/new.png"), tr("Home View"),this);
    mainViewAct->setStatusTip(tr("Main View"));
    connect(mainViewAct, SIGNAL(triggered()), this, SLOT(mainView()));

    thumbViewAct = new QAction(QIcon(":/images/save.png"), tr("Thumb view"), this);
    thumbViewAct->setStatusTip(tr("Show Thumb view"));
    connect(thumbViewAct, SIGNAL(triggered()), this, SLOT(thumbView()));
    
    questPollingAct = new QAction(QIcon(":/images/print.png"), tr("Question Polling"), this);
    questPollingAct->setStatusTip(tr("Show Question polling"));
    connect(questPollingAct, SIGNAL(triggered()), this, SLOT(questPolling()));
    
    showSessionEventAct = new QAction(QIcon(":/images/undo.png"), tr("Session Event"), this);
    showSessionEventAct->setStatusTip(tr("Show Session event"));
    connect(showSessionEventAct, SIGNAL(triggered()), this, SLOT(showSessionEvent()));
    

    }
    void MainWindow::mainView()
    {

    }
    void MainWindow::thumbView()
    {
    QList<int> lst1=childsplitter3->sizes();
    childsplitter2->setSizes(lst1);

    childsplitter2->setVisible(true);
    childsplitter3->setVisible(false);
    }
    void MainWindow::questPolling()
    {
    QList<int> lst2=childsplitter2->sizes();
    childsplitter3->setSizes(lst2);
    childsplitter3->setVisible(true);
    childsplitter2->setVisible(false);

    }
    void MainWindow::showSessionEvent()
    {

    }@

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

      I think you are using the wrong widgets. If you want either childsplitter2 or childsplitter3 visible, then I would suggest you put the contents of both of them in a QStackedWidget, and put the QStacked widget in the splitter next to whatever is in childsplitter1. That makes it trivial to programmatically switch the contents of the right hand pane of the splitter.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        M_31
        wrote on last edited by
        #3

        Its working fine...after the usuage of QStackedWidget.....
        thanks for your valuable input.........

        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