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;








1















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?










share|improve this question
























  • Do you want to expend the last column? something like this tw->horizontalHeader()->setStretchLastSection(true);

    – Simon
    Mar 27 at 16:51

















1















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?










share|improve this question
























  • Do you want to expend the last column? something like this tw->horizontalHeader()->setStretchLastSection(true);

    – Simon
    Mar 27 at 16:51













1












1








1








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?










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 27 at 16:48









annie5annie5

182 bronze badges




182 bronze badges















  • 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
















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












1 Answer
1






active

oldest

votes


















0















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.





share|improve this answer
























    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
    );



    );













    draft saved

    draft discarded


















    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









    0















    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.





    share|improve this answer





























      0















      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.





      share|improve this answer



























        0














        0










        0









        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.





        share|improve this answer













        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.






        share|improve this answer












        share|improve this answer



        share|improve this answer










        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





















            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.



















            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript