Why is there a space in QTreeWidget?
-
Hello I have a QTreeWidget. But when I add items to it, there are always spaces before the 1st column and after the last column.
Is there a way to remove them?
This post is deleted! -
@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);
@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?
-
@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);
@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.
-
@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);
@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
? -
@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
?@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);
-
@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);
@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 useqDebug()
.If the column count is as expected, then it may be Qt bug. Which Qt version are you using? On which platform?
-
@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 useqDebug()
.If the column count is as expected, then it may be Qt bug. Which Qt version are you using? On which platform?
@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 useqDebug()
.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 -
@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 useqDebug()
.If the column count is as expected, then it may be Qt bug. Which Qt version are you using? On which platform?
@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 useqDebug()
.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); -
@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 useqDebug()
.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);@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.
-
@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 useqDebug()
.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);@MasterBlade said in Why is there a space in QTreeWidget?:
Oh I found the problem.
Could you put the question as solved then? Cheers!~
-
@MasterBlade said in Why is there a space in QTreeWidget?:
Oh I found the problem.
Could you put the question as solved then? Cheers!~
@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!