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. Why is there a space in QTreeWidget?
Forum Updated to NodeBB v4.3 + New Features

Why is there a space in QTreeWidget?

Scheduled Pinned Locked Moved Solved General and Desktop
20 Posts 4 Posters 5.3k Views 2 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.
  • DiracsbracketD Diracsbracket

    @MasterBlade said in Why is there a space in QTreeWidget?:

    there are always spaces before the 1st column

    Try:

    ui->treeWidget->setRootIsDecorated(false); //is true by default, resulting in the space. This space is for a root-decoration image
    

    @MasterBlade said in Why is there a space in QTreeWidget?:

    and after the last column

    Try:

    ui->treeWidget->header()->setStretchLastSection(true);
    
    M Offline
    M Offline
    MasterBlade
    wrote on last edited by
    #11

    @Diracsbracket said in Why is there a space in QTreeWidget?:

    setRootIsDecorated(false);

    This Worked!! Many Thanks!!

    However I'm still having spaces at the end of the row.

    Every time I run this function, the space grows bigger. Is there a way to fix this?
    0_1525509109468_1.PNG

    1 Reply Last reply
    0
    • DiracsbracketD Diracsbracket

      @MasterBlade said in Why is there a space in QTreeWidget?:

      there are always spaces before the 1st column

      Try:

      ui->treeWidget->setRootIsDecorated(false); //is true by default, resulting in the space. This space is for a root-decoration image
      

      @MasterBlade said in Why is there a space in QTreeWidget?:

      and after the last column

      Try:

      ui->treeWidget->header()->setStretchLastSection(true);
      
      M Offline
      M Offline
      MasterBlade
      wrote on last edited by
      #12

      @Diracsbracket said in Why is there a space in QTreeWidget?:

      @MasterBlade said in Why is there a space in QTreeWidget?:

      and after the last column

      Try:

      ui->treeWidget->header()->setStretchLastSection(true);
      

      Actually I already set this in Form View.
      0_1525509231624_2.PNG

      1 Reply Last reply
      0
      • DiracsbracketD Diracsbracket

        @MasterBlade said in Why is there a space in QTreeWidget?:

        there are always spaces before the 1st column

        Try:

        ui->treeWidget->setRootIsDecorated(false); //is true by default, resulting in the space. This space is for a root-decoration image
        

        @MasterBlade said in Why is there a space in QTreeWidget?:

        and after the last column

        Try:

        ui->treeWidget->header()->setStretchLastSection(true);
        
        DiracsbracketD Offline
        DiracsbracketD Offline
        Diracsbracket
        wrote on last edited by Diracsbracket
        #13

        @Diracsbracket said in Why is there a space in QTreeWidget?:

        ui->treeWidget->header()->setStretchLastSection(true);

        Sorry, this is true by default, so wouldn't help in your case.

        @MasterBlade said in Why is there a space in QTreeWidget?:

        However I'm still having spaces at the end of the row.

        What value is returned by

        qDebug()  << ui->treeWidget->columnCount() ;
        

        Somehow, it seems there is an extra empty column in your QTreeWidget ?

        M 1 Reply Last reply
        0
        • DiracsbracketD Diracsbracket

          @Diracsbracket said in Why is there a space in QTreeWidget?:

          ui->treeWidget->header()->setStretchLastSection(true);

          Sorry, this is true by default, so wouldn't help in your case.

          @MasterBlade said in Why is there a space in QTreeWidget?:

          However I'm still having spaces at the end of the row.

          What value is returned by

          qDebug()  << ui->treeWidget->columnCount() ;
          

          Somehow, it seems there is an extra empty column in your QTreeWidget ?

          M Offline
          M Offline
          MasterBlade
          wrote on last edited by
          #14

          @Diracsbracket said in Why is there a space in QTreeWidget?:

          @Diracsbracket said in Why is there a space in QTreeWidget?:

          ui->treeWidget->header()->setStretchLastSection(true);

          Sorry, this is true by default, so wouldn't help in your case.

          @MasterBlade said in Why is there a space in QTreeWidget?:

          However I'm still having spaces at the end of the row.

          What value is returned by

          qDebug()  << ui->treeWidget->columnCount() ;
          

          Somehow, it seems there is an extra empty column in your QTreeWidget ?

          I'm sorry but I'm having problem with the debugging. It won't pass.

          ..\MasterZMDJ\deck.cpp:305:12: error: invalid use of incomplete type 'class QDebug'
          qDebug() << ui->DeckList->columnCount() ;
          ^

          Also I added the following. The space is not growing as the function is called. But there is still a space at the end.

          ui->DeckList->header()->setStretchLastSection(true);
          
          DiracsbracketD 1 Reply Last reply
          0
          • M MasterBlade

            @Diracsbracket said in Why is there a space in QTreeWidget?:

            @Diracsbracket said in Why is there a space in QTreeWidget?:

            ui->treeWidget->header()->setStretchLastSection(true);

            Sorry, this is true by default, so wouldn't help in your case.

            @MasterBlade said in Why is there a space in QTreeWidget?:

            However I'm still having spaces at the end of the row.

            What value is returned by

            qDebug()  << ui->treeWidget->columnCount() ;
            

            Somehow, it seems there is an extra empty column in your QTreeWidget ?

            I'm sorry but I'm having problem with the debugging. It won't pass.

            ..\MasterZMDJ\deck.cpp:305:12: error: invalid use of incomplete type 'class QDebug'
            qDebug() << ui->DeckList->columnCount() ;
            ^

            Also I added the following. The space is not growing as the function is called. But there is still a space at the end.

            ui->DeckList->header()->setStretchLastSection(true);
            
            DiracsbracketD Offline
            DiracsbracketD Offline
            Diracsbracket
            wrote on last edited by Diracsbracket
            #15

            @MasterBlade said in Why is there a space in QTreeWidget?:

            ..\MasterZMDJ\deck.cpp:305:12: error: invalid use of incomplete type 'class QDebug'

            You must include <QDebug> to use qDebug().

            If the column count is as expected, then it may be Qt bug. Which Qt version are you using? On which platform?

            M 2 Replies Last reply
            1
            • DiracsbracketD Diracsbracket

              @MasterBlade said in Why is there a space in QTreeWidget?:

              ..\MasterZMDJ\deck.cpp:305:12: error: invalid use of incomplete type 'class QDebug'

              You must include <QDebug> to use qDebug().

              If the column count is as expected, then it may be Qt bug. Which Qt version are you using? On which platform?

              M Offline
              M Offline
              MasterBlade
              wrote on last edited by
              #16

              @Diracsbracket said in Why is there a space in QTreeWidget?:

              @MasterBlade said in Why is there a space in QTreeWidget?:

              ..\MasterZMDJ\deck.cpp:305:12: error: invalid use of incomplete type 'class QDebug'

              You must include <QDebug> to use qDebug().

              If the column count is as expected, then it may be Qt bug. Which Qt version are you using? On which platform?

              The return value is 3.
              I'm using Qt Creator 4.6.1. Based on Qt 5.10.1 (MSVC 2015,32 bit) on Windows 10 x64

              1 Reply Last reply
              0
              • DiracsbracketD Diracsbracket

                @MasterBlade said in Why is there a space in QTreeWidget?:

                ..\MasterZMDJ\deck.cpp:305:12: error: invalid use of incomplete type 'class QDebug'

                You must include <QDebug> to use qDebug().

                If the column count is as expected, then it may be Qt bug. Which Qt version are you using? On which platform?

                M Offline
                M Offline
                MasterBlade
                wrote on last edited by
                #17

                @Diracsbracket said in Why is there a space in QTreeWidget?:

                @MasterBlade said in Why is there a space in QTreeWidget?:

                ..\MasterZMDJ\deck.cpp:305:12: error: invalid use of incomplete type 'class QDebug'

                You must include <QDebug> to use qDebug().

                If the column count is as expected, then it may be Qt bug. Which Qt version are you using? On which platform?

                Oh I found the problem. It's on the sorting function.
                When I comment this line, everything turns out just fine.
                ui->DeckList->sortByColumn(1, Qt::AscendingOrder);

                DiracsbracketD 2 Replies Last reply
                0
                • M MasterBlade

                  @Diracsbracket said in Why is there a space in QTreeWidget?:

                  @MasterBlade said in Why is there a space in QTreeWidget?:

                  ..\MasterZMDJ\deck.cpp:305:12: error: invalid use of incomplete type 'class QDebug'

                  You must include <QDebug> to use qDebug().

                  If the column count is as expected, then it may be Qt bug. Which Qt version are you using? On which platform?

                  Oh I found the problem. It's on the sorting function.
                  When I comment this line, everything turns out just fine.
                  ui->DeckList->sortByColumn(1, Qt::AscendingOrder);

                  DiracsbracketD Offline
                  DiracsbracketD Offline
                  Diracsbracket
                  wrote on last edited by Diracsbracket
                  #18

                  @MasterBlade said in Why is there a space in QTreeWidget?:

                  When I comment this line, everything turns out just fine.

                  Which in itself is weird... sorting should not affect the layout of the treeWidget in that way.

                  1 Reply Last reply
                  0
                  • M MasterBlade

                    @Diracsbracket said in Why is there a space in QTreeWidget?:

                    @MasterBlade said in Why is there a space in QTreeWidget?:

                    ..\MasterZMDJ\deck.cpp:305:12: error: invalid use of incomplete type 'class QDebug'

                    You must include <QDebug> to use qDebug().

                    If the column count is as expected, then it may be Qt bug. Which Qt version are you using? On which platform?

                    Oh I found the problem. It's on the sorting function.
                    When I comment this line, everything turns out just fine.
                    ui->DeckList->sortByColumn(1, Qt::AscendingOrder);

                    DiracsbracketD Offline
                    DiracsbracketD Offline
                    Diracsbracket
                    wrote on last edited by
                    #19

                    @MasterBlade said in Why is there a space in QTreeWidget?:

                    Oh I found the problem.

                    Could you put the question as solved then? Cheers!~

                    M 1 Reply Last reply
                    1
                    • DiracsbracketD Diracsbracket

                      @MasterBlade said in Why is there a space in QTreeWidget?:

                      Oh I found the problem.

                      Could you put the question as solved then? Cheers!~

                      M Offline
                      M Offline
                      MasterBlade
                      wrote on last edited by
                      #20

                      @Diracsbracket said in Why is there a space in QTreeWidget?:

                      @MasterBlade said in Why is there a space in QTreeWidget?:

                      Oh I found the problem.

                      Could you put the question as solved then? Cheers!~

                      Sure, thanks for the help!

                      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