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. [SOLVED] Horizontal stretch of QProgressBar within a QGridLayout
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] Horizontal stretch of QProgressBar within a QGridLayout

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.7k 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.
  • T Offline
    T Offline
    TOAOMatis
    wrote on last edited by
    #1

    Hi all,

    I'm using Qt 5.2.1 on Xubuntu 12.04 and I'm running into the following problem. Within my GUI I have a QGroupBox that holds a derived QGridLayout.
    Within this derived QGridLayout a add several QWidgets:
    @void ProgramState::setupWidgets(QWidget *parent)
    {
    lblState = new QLabel(parent);
    lblState->setText("Info");

    pbProgress = new QProgressBar(parent);
    pbProgress->setRange(0, 100);
    pbProgress->setValue(50);
    
    btnStart = new QPushButton(parent);
    btnStart->setText("Start");
    btnStart->setEnabled(false);
    
    btnStop = new QPushButton(parent);
    btnStop->setText("Stop");
    btnStop->setEnabled(false);
    
    this->addWidget(pbProgress, 0, 0, 1, 6, Qt::AlignCenter);
    this->addWidget(lblState, 1, 0, 2, 2, Qt::AlignCenter);
    this->addWidget(btnStart, 1, 2, 1, 2, Qt::AlignCenter);
    this->addWidget(btnStop, 1, 4, 1, 2, Qt::AlignCenter);
    

    }@

    The QWidgets are added in the right cell (grid) and each grid has the right column span.
    !http://matis-digital.com/shutter/server/php/files/2014_03_17_Selection_01.png(Layout)!

    Unfortunately, I can't seem to find a way to strecht the QProgressBar across the whole width of the grid.

    Is there an (easy) way of achieving the auto stretching of the QProgressBar across the whole width of the QGridLayout?

    Thnaks in advance,

    TOAOMatis

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Yes, remove Qt::AlignCenter from the progress. You don't want it to center. You want it to stretch (the default) ;)

      1 Reply Last reply
      0
      • T Offline
        T Offline
        TOAOMatis
        wrote on last edited by
        #3

        Damn, I must have overseen that a dozen times :$

        Thanks for your reply. It works like a charm now!

        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