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. how to place QWidget widget in the center of QHboxlayout
Forum Updated to NodeBB v4.3 + New Features

how to place QWidget widget in the center of QHboxlayout

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 1.1k Views 1 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by VRonin
    #1
      QVBoxLayout* vlayout = new QVBoxLayout;
      QHBoxLayout* hlayout = new QHBoxLayout;
      textBrowser_1 = new QTextEdit;
      textBrowser_2 = new QTextEdit;
      QWidget* widget = new QWidget; 
      splitter =new QSplitter(Qt::Horizontal,this);
      splitter->addWidget(textBrowser_1); 
      splitter->addWidget(textBrowser_2); 
    
      button1 = new QPushButton("OK");
      button2 = new QPushButton("Cancel");
      hlayout->addWidget(button1);
      hlayout->addWidget(button2);
      widget->setLayout(hlayout);
      widget->setMaximumWidth(200);
    
      vlayout->addWidget(splitter);
      vlayout->addWidget(widget);
      button1->setMaximumHeight(40);
      button1->setMaximumHeight(40);
      button1->setMaximumWidth(75);
      button1->setMaximumWidth(75);
    
      button2->setMaximumHeight(40);
      button2->setMaximumHeight(40);
      button2->setMaximumWidth(75);
      button2->setMaximumWidth(75);
    

    basically I want to place the two buttons ate the center of my Widget how to do that ?

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2
      hlayout->addStretch();
      hlayout->addWidget(button1);
      hlayout->addWidget(button2);
      hlayout->addStretch();
      

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      3

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved