How to keep the size of second column of a QtreeWidget (with more than 2 columns) dynamic?C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?Image Processing: Algorithm Improvement for 'Coca-Cola Can' RecognitionHow to read columns in qtreeWidget?How to incorporate Ctrl+RightClick (i.e. multiple selection) facility in qtreeWidget?Adding Children in the second column of QTreeWidget using C++QTreeWidget vertical scrollbar jumps too farReplacing a 32-bit loop counter with 64-bit introduces crazy performance deviationsQTreeWidget - width of column with widgetDynamic size of QTreeWidget in PyQt5Minimum vertical size of a collapsed QTreeWidget is too large
Justifying the use of directed energy weapons
What is the history of the university asylum law?
Why is less being run unnecessarily by git?
Is my soulless catatonic body a valid target for the Imprisonment spell?
Singleton Design Pattern implementation in a not traditional way
Mathematical uses of string theory
Was Switzerland really impossible to invade during WW2?
Would it be possible to have a GMO that produces chocolate?
Why is Boris Johnson visiting only Paris & Berlin if every member of the EU needs to agree on a withdrawal deal?
Why does The Ancient One think differently about Doctor Strange in Endgame than the film Doctor Strange?
How can I watch the 17th (or last, if less) line in files of a folder?
1980's sci fi book series, subspace is a sponge, young man in emergency suit can propel himself by sucking in the sponge stuff
Who was president?
What are some interesting features that are common cross-linguistically but don't exist in English?
Middle Mouse turns on Perspective
Are there account age or level requirements for obtaining special research?
Why did MS-DOS applications built using Turbo Pascal fail to start with a division by zero error on faster systems?
Deck Size Problems in Deckbuilding
Why is my Earth simulation slower than the reality?
Can a gem used as the material component for the Magic Jar spell also be used for the Imprisonment spell?
C++20 constexpr std::copy optimizations for run-time
Using `With[...]` with a list specification as a variable
Is there a known non-euclidean geometry where two concentric circles of different radii can intersect? (as in the novel "The Universe Between")
Start from ones
How to keep the size of second column of a QtreeWidget (with more than 2 columns) dynamic?
C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?Image Processing: Algorithm Improvement for 'Coca-Cola Can' RecognitionHow to read columns in qtreeWidget?How to incorporate Ctrl+RightClick (i.e. multiple selection) facility in qtreeWidget?Adding Children in the second column of QTreeWidget using C++QTreeWidget vertical scrollbar jumps too farReplacing a 32-bit loop counter with 64-bit introduces crazy performance deviationsQTreeWidget - width of column with widgetDynamic size of QTreeWidget in PyQt5Minimum vertical size of a collapsed QTreeWidget is too large
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have a mainwindow with Qtreewidget(having 3 columns) as central widget. I want to keep the size of first and second column fixed, but the size of second column should be equal to the size of qtreewidget minus the size of other two columns. Since the size of mainwindow (also, treewidget) can be changed, how to keep the second column size changing as well?
c++ qt qtreewidget
add a comment |
I have a mainwindow with Qtreewidget(having 3 columns) as central widget. I want to keep the size of first and second column fixed, but the size of second column should be equal to the size of qtreewidget minus the size of other two columns. Since the size of mainwindow (also, treewidget) can be changed, how to keep the second column size changing as well?
c++ qt qtreewidget
Do you want to expend the last column? something like thistw->horizontalHeader()->setStretchLastSection(true);
– Simon
Mar 27 at 16:51
add a comment |
I have a mainwindow with Qtreewidget(having 3 columns) as central widget. I want to keep the size of first and second column fixed, but the size of second column should be equal to the size of qtreewidget minus the size of other two columns. Since the size of mainwindow (also, treewidget) can be changed, how to keep the second column size changing as well?
c++ qt qtreewidget
I have a mainwindow with Qtreewidget(having 3 columns) as central widget. I want to keep the size of first and second column fixed, but the size of second column should be equal to the size of qtreewidget minus the size of other two columns. Since the size of mainwindow (also, treewidget) can be changed, how to keep the second column size changing as well?
c++ qt qtreewidget
c++ qt qtreewidget
asked Mar 27 at 16:48
annie5annie5
182 bronze badges
182 bronze badges
Do you want to expend the last column? something like thistw->horizontalHeader()->setStretchLastSection(true);
– Simon
Mar 27 at 16:51
add a comment |
Do you want to expend the last column? something like thistw->horizontalHeader()->setStretchLastSection(true);
– Simon
Mar 27 at 16:51
Do you want to expend the last column? something like this
tw->horizontalHeader()->setStretchLastSection(true);
– Simon
Mar 27 at 16:51
Do you want to expend the last column? something like this
tw->horizontalHeader()->setStretchLastSection(true);
– Simon
Mar 27 at 16:51
add a comment |
1 Answer
1
active
oldest
votes
Using header()
funtion of QTreeWidget
, you can get the QHeaderView
object.
In the document link(https://doc.qt.io/qt-5/qtreeview.html#sizeHintForColumn), you notice that
If you need to set the width of a given column to a fixed value, call
QHeaderView::resizeSection() on the view's header.
void QHeaderView::resizeSection(int logicalIndex, int size)
So the rough code could be:
QHeaderView* headerView = treeWidget->header();
headerView->resizeSection(COLUMN_INDEX, FIXEDSIZE); //Calculate the required size and do this for required columns.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55382523%2fhow-to-keep-the-size-of-second-column-of-a-qtreewidget-with-more-than-2-columns%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Using header()
funtion of QTreeWidget
, you can get the QHeaderView
object.
In the document link(https://doc.qt.io/qt-5/qtreeview.html#sizeHintForColumn), you notice that
If you need to set the width of a given column to a fixed value, call
QHeaderView::resizeSection() on the view's header.
void QHeaderView::resizeSection(int logicalIndex, int size)
So the rough code could be:
QHeaderView* headerView = treeWidget->header();
headerView->resizeSection(COLUMN_INDEX, FIXEDSIZE); //Calculate the required size and do this for required columns.
add a comment |
Using header()
funtion of QTreeWidget
, you can get the QHeaderView
object.
In the document link(https://doc.qt.io/qt-5/qtreeview.html#sizeHintForColumn), you notice that
If you need to set the width of a given column to a fixed value, call
QHeaderView::resizeSection() on the view's header.
void QHeaderView::resizeSection(int logicalIndex, int size)
So the rough code could be:
QHeaderView* headerView = treeWidget->header();
headerView->resizeSection(COLUMN_INDEX, FIXEDSIZE); //Calculate the required size and do this for required columns.
add a comment |
Using header()
funtion of QTreeWidget
, you can get the QHeaderView
object.
In the document link(https://doc.qt.io/qt-5/qtreeview.html#sizeHintForColumn), you notice that
If you need to set the width of a given column to a fixed value, call
QHeaderView::resizeSection() on the view's header.
void QHeaderView::resizeSection(int logicalIndex, int size)
So the rough code could be:
QHeaderView* headerView = treeWidget->header();
headerView->resizeSection(COLUMN_INDEX, FIXEDSIZE); //Calculate the required size and do this for required columns.
Using header()
funtion of QTreeWidget
, you can get the QHeaderView
object.
In the document link(https://doc.qt.io/qt-5/qtreeview.html#sizeHintForColumn), you notice that
If you need to set the width of a given column to a fixed value, call
QHeaderView::resizeSection() on the view's header.
void QHeaderView::resizeSection(int logicalIndex, int size)
So the rough code could be:
QHeaderView* headerView = treeWidget->header();
headerView->resizeSection(COLUMN_INDEX, FIXEDSIZE); //Calculate the required size and do this for required columns.
answered Mar 27 at 17:06
Pavan ChandakaPavan Chandaka
6,0103 gold badges12 silver badges22 bronze badges
6,0103 gold badges12 silver badges22 bronze badges
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55382523%2fhow-to-keep-the-size-of-second-column-of-a-qtreewidget-with-more-than-2-columns%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Do you want to expend the last column? something like this
tw->horizontalHeader()->setStretchLastSection(true);
– Simon
Mar 27 at 16:51