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. BUMP - how to code "main window display area "?

BUMP - how to code "main window display area "?

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 4 Posters 1.4k 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.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by
    #1

    I like to use / reuse the QMainWindow area - between tool bar icons and status bar - to add widgets into.

    .

    Does it have an official name ?
    How do I get its size ?

    I prefer NOT to disrupt working QDesigner ui setup...

    This code takes the entire area

    setCentralWidget(m_console);
    

    and I like to share the SAME area with more widgets.

    and example code or link would be nice

    Thanks

    36528b0a-336a-4293-a7d9-d6bcd37015c0-image.png

    Axel SpoerlA JonBJ Christian EhrlicherC 3 Replies Last reply
    0
    • A Anonymous_Banned275

      I like to use / reuse the QMainWindow area - between tool bar icons and status bar - to add widgets into.

      .

      Does it have an official name ?
      How do I get its size ?

      I prefer NOT to disrupt working QDesigner ui setup...

      This code takes the entire area

      setCentralWidget(m_console);
      

      and I like to share the SAME area with more widgets.

      and example code or link would be nice

      Thanks

      36528b0a-336a-4293-a7d9-d6bcd37015c0-image.png

      Axel SpoerlA Offline
      Axel SpoerlA Offline
      Axel Spoerl
      Moderators
      wrote on last edited by
      #2

      @AnneRanch

      mainWindow->show();
      dDebug() << mainWindow->centralWidget()->size();
      

      Software Engineer
      The Qt Company, Oslo

      1 Reply Last reply
      0
      • A Anonymous_Banned275

        I like to use / reuse the QMainWindow area - between tool bar icons and status bar - to add widgets into.

        .

        Does it have an official name ?
        How do I get its size ?

        I prefer NOT to disrupt working QDesigner ui setup...

        This code takes the entire area

        setCentralWidget(m_console);
        

        and I like to share the SAME area with more widgets.

        and example code or link would be nice

        Thanks

        36528b0a-336a-4293-a7d9-d6bcd37015c0-image.png

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @AnneRanch
        You make it a QWidget, you set some layout on it, you add console widget somewhere on layout and you can add whatever other widgets you like elsewhere on layout.

        A 1 Reply Last reply
        2
        • A Anonymous_Banned275

          I like to use / reuse the QMainWindow area - between tool bar icons and status bar - to add widgets into.

          .

          Does it have an official name ?
          How do I get its size ?

          I prefer NOT to disrupt working QDesigner ui setup...

          This code takes the entire area

          setCentralWidget(m_console);
          

          and I like to share the SAME area with more widgets.

          and example code or link would be nice

          Thanks

          36528b0a-336a-4293-a7d9-d6bcd37015c0-image.png

          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @AnneRanch said in BUMP - how to code "main window display area "?:

          and I like to share the SAME area with more widgets.

          Already asked and answered here two times:
          https://forum.qt.io/topic/155963
          https://forum.qt.io/topic/155559

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          1
          • JonBJ JonB

            @AnneRanch
            You make it a QWidget, you set some layout on it, you add console widget somewhere on layout and you can add whatever other widgets you like elsewhere on layout.

            A Offline
            A Offline
            Anonymous_Banned275
            wrote on last edited by
            #5

            @JonB Here is my current TEST code:

            
                QPushButton* but1 = new QPushButton("Button 1");
                QPushButton* but2 = new QPushButton("Button 2");
                QPushButton* but3 = new QPushButton("Button 3");
            
                this->layout()->addWidget(but1);
            

            It uses "this" layout and "takes over: the entire area " = including the menu and icons bars. No good.

            I can (probably ) move the button around, but I want to keep the menus and icons,

            When I build another layout

            // QHBoxLayout *layout = new QHBoxLayout;
            // layout->addWidget(but2);
            // layout->setEnabled(true);
            // this->setLayout(layout);

            I get same " wiped out whole area " but NO button.

            I do not want to ask yes /no questions , nor (care for ) receiving statistical data,
            but
            do I really need to code another "layout" - on top of the "this" default "layout (manger ) " ?

            Thanks

            JonBJ Axel SpoerlA 2 Replies Last reply
            0
            • A Anonymous_Banned275

              @JonB Here is my current TEST code:

              
                  QPushButton* but1 = new QPushButton("Button 1");
                  QPushButton* but2 = new QPushButton("Button 2");
                  QPushButton* but3 = new QPushButton("Button 3");
              
                  this->layout()->addWidget(but1);
              

              It uses "this" layout and "takes over: the entire area " = including the menu and icons bars. No good.

              I can (probably ) move the button around, but I want to keep the menus and icons,

              When I build another layout

              // QHBoxLayout *layout = new QHBoxLayout;
              // layout->addWidget(but2);
              // layout->setEnabled(true);
              // this->setLayout(layout);

              I get same " wiped out whole area " but NO button.

              I do not want to ask yes /no questions , nor (care for ) receiving statistical data,
              but
              do I really need to code another "layout" - on top of the "this" default "layout (manger ) " ?

              Thanks

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @AnneRanch

              QWidget *widget = new QWidget;
              setCentralWidget(widget);
              QVBoxLayout *layout = new QVBoxLayout(widget);    // or whatever layout kind you want
              layout->addWidget(console);
              layout->addWidget(someotherwidget);
              layout->addWidget(somePushButton);
              ....
              

              Now you have multiple widgets in the main window central layout, instead of just console. That's how you do it if that is what you want. You can also do this from Designer.

              this->setLayout(layout); will never be right if this is a QMainWindow, but I don't know what your this is.

              1 Reply Last reply
              2
              • A Anonymous_Banned275

                @JonB Here is my current TEST code:

                
                    QPushButton* but1 = new QPushButton("Button 1");
                    QPushButton* but2 = new QPushButton("Button 2");
                    QPushButton* but3 = new QPushButton("Button 3");
                
                    this->layout()->addWidget(but1);
                

                It uses "this" layout and "takes over: the entire area " = including the menu and icons bars. No good.

                I can (probably ) move the button around, but I want to keep the menus and icons,

                When I build another layout

                // QHBoxLayout *layout = new QHBoxLayout;
                // layout->addWidget(but2);
                // layout->setEnabled(true);
                // this->setLayout(layout);

                I get same " wiped out whole area " but NO button.

                I do not want to ask yes /no questions , nor (care for ) receiving statistical data,
                but
                do I really need to code another "layout" - on top of the "this" default "layout (manger ) " ?

                Thanks

                Axel SpoerlA Offline
                Axel SpoerlA Offline
                Axel Spoerl
                Moderators
                wrote on last edited by
                #7

                @AnneRanch

                this->layout()
                

                …is the main window layout, which isn’t meant to host other apps widgets. That’s what the central widget and its layout is supposed to handle. It also gives you the freedom to choose if it’s vertical, horizontal, or a grid. „Coding another layout“ is a two liner. Why are you reluctant about it?

                Software Engineer
                The Qt Company, Oslo

                A 1 Reply Last reply
                1
                • Axel SpoerlA Axel Spoerl

                  @AnneRanch

                  this->layout()
                  

                  …is the main window layout, which isn’t meant to host other apps widgets. That’s what the central widget and its layout is supposed to handle. It also gives you the freedom to choose if it’s vertical, horizontal, or a grid. „Coding another layout“ is a two liner. Why are you reluctant about it?

                  A Offline
                  A Offline
                  Anonymous_Banned275
                  wrote on last edited by
                  #8

                  Addendum PROGRESS UPDATE

                  OK, I finally got the picture and it is working.
                  However, I got spoil using QDesigner for ui...
                  I decided to combine code and QDesigner.

                  For now I have the original m_console and newly build TAB widget class using QDesigner...

                  Small issue
                  I cannot get BOTH m_console and m_form_tab to show up TOGETHER .

                  ...only one or the other , not both

                  what am I missing ?

                     // build ui form
                      m_form_tab = new Form_TAB();
                      m_form_tab->show();
                  
                  
                      // test widgets
                      QPushButton* but1 = new QPushButton("Button 1");
                      QPushButton* but2 = new QPushButton("Button 2");
                      QPushButton* but3 = new QPushButton("Button 3");
                  
                      QWidget *widget = new QWidget;
                      setCentralWidget(widget);
                      QVBoxLayout *layout = new QVBoxLayout(widget);    
                  
                   ///   layout->addWidget(m_console);
                      **layout->addWidget( m_form_tab); no go ! 
                      layout->addWidget(m_console);**
                  
                  Axel SpoerlA 1 Reply Last reply
                  0
                  • A Anonymous_Banned275

                    Addendum PROGRESS UPDATE

                    OK, I finally got the picture and it is working.
                    However, I got spoil using QDesigner for ui...
                    I decided to combine code and QDesigner.

                    For now I have the original m_console and newly build TAB widget class using QDesigner...

                    Small issue
                    I cannot get BOTH m_console and m_form_tab to show up TOGETHER .

                    ...only one or the other , not both

                    what am I missing ?

                       // build ui form
                        m_form_tab = new Form_TAB();
                        m_form_tab->show();
                    
                    
                        // test widgets
                        QPushButton* but1 = new QPushButton("Button 1");
                        QPushButton* but2 = new QPushButton("Button 2");
                        QPushButton* but3 = new QPushButton("Button 3");
                    
                        QWidget *widget = new QWidget;
                        setCentralWidget(widget);
                        QVBoxLayout *layout = new QVBoxLayout(widget);    
                    
                     ///   layout->addWidget(m_console);
                        **layout->addWidget( m_form_tab); no go ! 
                        layout->addWidget(m_console);**
                    
                    Axel SpoerlA Offline
                    Axel SpoerlA Offline
                    Axel Spoerl
                    Moderators
                    wrote on last edited by
                    #9

                    Good that you have it working and thanks for letting us know!

                    If you write a post, please re-read it before posting and put yourself in the position of someone who tries to help you.
                    Had you done it this time, you may have realized that you don’t tell, what

                    m_console
                    

                    is. Where it’s declared, instantiated, if you have ever shown it before or done other things with it.

                    How do you think anybody can answer your question without this critical piece of information?

                    Software Engineer
                    The Qt Company, Oslo

                    A 1 Reply Last reply
                    0
                    • Axel SpoerlA Axel Spoerl

                      Good that you have it working and thanks for letting us know!

                      If you write a post, please re-read it before posting and put yourself in the position of someone who tries to help you.
                      Had you done it this time, you may have realized that you don’t tell, what

                      m_console
                      

                      is. Where it’s declared, instantiated, if you have ever shown it before or done other things with it.

                      How do you think anybody can answer your question without this critical piece of information?

                      A Offline
                      A Offline
                      Anonymous_Banned275
                      wrote on last edited by
                      #10

                      UPDATE
                      I have narrowed it down to TAB widget....
                      STAND BY

                      5c0cd0a8-52fe-4d28-9a27-4590c5add7c8-image.png

                      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