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]Space between widgets ( added to QSplitter )

[SOLVED]Space between widgets ( added to QSplitter )

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 8.9k 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.
  • S Offline
    S Offline
    Sorin
    wrote on last edited by
    #1

    I have a QScrollArea and a QtreeWidget added to a QSplitter:

    @QSplitter* someSplitter = new QSplitter( parent );
    someSplitter->addWidget( firstWidget );
    someSplitter->addWidget( secondWidget );

    //I want the space between my widgets to very small
    QSplitterHandle *handle = someSplitter->handle(1);
    handle->setMaximumWidth( 1 );
    //indeed the splitter handle will have width = 1 but the space between widgets is still there, how can I get rid of it?

    @
    Thanks!

    There are only 10 types of people in the world: Those who understand binary, and those who don't

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      Did you set the contents margins of the layouts of firstWidget/secondWidget (see "QLayout::setContentsMargins()":http://doc.qt.nokia.com/4.7/qlayout.html#setContentsMargins and "QWidget::setContentsMargins()":http://doc.qt.nokia.com/4.7/qwidget.html#setContentsMargins).

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Sorin
        wrote on last edited by
        #3

        did that too, not working, I implemented a small example that reproduces the behaviour:

        @#include<QApplication>
        #include<QSplitter>

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

        QSplitter* splitter = new QSplitter;
        splitter->setFixedSize( 300, 300 );
        QWidget* widget1 = new QWidget( splitter );
        QWidget* widget2 = new QWidget( splitter );
        widget1->setStyleSheet( "QWidget{ background: red}" );
        widget2->setStyleSheet( "QWidget{ background: blue}" );
        
        widget1->setContentsMargins( 0,0,0,0 );
        widget2->setContentsMargins( 0,0,0,0 );
        
        splitter->addWidget( widget1 );
        splitter->addWidget( widget2 );
        
        //I want that the space between widgets to be only a line
        QSplitterHandle *handle = splitter->handle(1);
        handle->setFixedWidth( 1 );
        
        splitter->show();
        
        return app.exec(&#41;;
        

        }@

        There are only 10 types of people in the world: Those who understand binary, and those who don't

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          Use

          @
          splitter->setHandleWidth(1);
          @

          This sets the width of all handles of the splitter to width 1.

          http://www.catb.org/~esr/faqs/smart-questions.html

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

            worked, thanks

            There are only 10 types of people in the world: Those who understand binary, and those who don't

            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