[SOLVED]Help on QSplitter



  • 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()
    {

    }@



  • 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.



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


Log in to reply
 

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