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. A few big questions about splitter windows
QtWS25 Last Chance

A few big questions about splitter windows

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 4.2k Views
  • 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.
  • A Offline
    A Offline
    AutoBot
    wrote on last edited by
    #1

    My first question is... why won't this code work?
    @#include <QApplication>
    #include <QSplitter>
    #include <QListView>
    #include <QTreeView>
    #include <QTextEdit>

    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);

    QSplitter *splitter = new QSplitter;
    QListView *listview = new QListView;
    QTreeView *treeview = new QTreeView;
    QTextEdit *textedit = new QTextEdit;
    splitter->addWidget(listview);
    splitter->addWidget(treeview);
    splitter->addWidget(textedit);
    
    return app.exec();
    

    }
    @

    It compiles with no errors, but when I run it nothing shows up. Do I need to initialize the parent parameter, and if so to what? Forgive me as I'm rather new to Qt programming.
    And antoher question, how do I use QSplitterHandle, and how is it implemented differently from QSplitter?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      silver47
      wrote on last edited by
      #2

      You forgot to show splitter.
      @splitter->show();@

      sorry for my english :(

      1 Reply Last reply
      0
      • L Offline
        L Offline
        loladiro
        wrote on last edited by
        #3

        About your second question, let me quote the "documentation":http://doc.qt.nokia.com/4.7/qsplitterhandle.html#details

        [quote]
        The QSplitterHandle class provides handle functionality of the splitter.

        QSplitterHandle is typically what people think about when they think about a splitter. It is the handle that is used to resize the widgets.

        A typical developer using QSplitter will never have to worry about QSplitterHandle. It is provided for developers who want splitter handles that provide extra features, such as popup menus.
        [/quote]

        1 Reply Last reply
        0
        • A Offline
          A Offline
          AutoBot
          wrote on last edited by
          #4

          I apologize about the splitterhandle question, they just slip through sometimes I guess. xD I'll look more carefully next time.

          The show function worked by the way, thanks! I do have another question though, is there a standard way to create a type of "quad splitter" (or splitter that has both horizontal and vertical properties)? One thing that comes to mind is I could have 2 horizontal child splitters, each with two, say, opengl viewports, and then I would add these splitters to a vertical parent splitter. But is there a more standard way to do this that Qt already has implemented?

          EDIT: I've tried implementing the splitter in the way I described. The horizontal bar works correctly, but the vertical one acts like two separite bars. So that won't really work the way I thought.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SeroBuro
            wrote on last edited by
            #5

            A probable idea for such a construst you want to make, I think, is to make a QTableView, where each cell represented by a QWidget - this done by reimplementing QItemDelegate's all virtual functions.
            But it is a rather complicated way :)
            The other way I see is to reimplement QSplitter in a very simple way - add a slot, that just calls moveSplitter ( int pos, int index ) (it is a protected function). Then, you just connect splitterMoved( int pos, int index ) signal to new slot of other splitter for both your separate bars in example above. The only problem I see here is a probable infinite loop, if there is no protection in moveSplitter( int pos, int index ) (no checking for equality of new and old pos)

            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