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. Can't hide group box in Qt
Forum Updated to NodeBB v4.3 + New Features

Can't hide group box in Qt

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.9k 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.
  • B Offline
    B Offline
    boomboom2013
    wrote on last edited by
    #1

    I'm learning GUI programming with qt. I have a problem with Shape-Changing Dialogs. Like this:
    !http://i.stack.imgur.com/fTzzJ.jpg(blah)!
    To do so, I added some signal-slot, like
    @connect(ui->pbMore,SIGNAL(toggled(bool)),ui->gbSecond,SLOT(setShown(bool)));@

    but it ain't work. I tried

    @setVisible(bool)@

    or set the connection on the GUI but no luck either.

    This is an example from the book C++ GUI Programming with Qt 4, Second Edition. They do the same way with me. So what's my mistake?

    Edit: add ui file and codes.

    dialogexpand.h

    @#ifndef DIALOGEXPAND_H
    #define DIALOGEXPAND_H

    #include <QDialog>

    namespace Ui {
    class DialogExpand;
    }

    class DialogExpand : public QDialog
    {
    Q_OBJECT

    public:
    explicit DialogExpand(QWidget *parent = 0);
    ~DialogExpand();

    private:
    Ui::DialogExpand *ui;
    public:
    void SortDialog(QWidget *parent = 0);
    void setColumnRange(QChar first, QChar last);
    };@
    dialogexpand.cpp

    @#include "dialogexpand.h"
    #include "ui_dialogexpand.h"

    DialogExpand::DialogExpand(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DialogExpand)
    {
    ui->setupUi(this);

    connect(ui->pbMore,SIGNAL(toggled(bool)),ui->gSec,SLOT(setVisible(bool)));
    connect(ui->pbMore,SIGNAL(toggled(bool)),ui->gbThird,SLOT(setShown(bool)));
    

    // ui->gbThird->hide();
    // ui->gSec->hide();
    SortDialog();
    }

    DialogExpand::~DialogExpand()
    {
    delete ui;
    }

    void DialogExpand::SortDialog(QWidget *parent)
    {

    // ui->gSec->hide();
    // ui->gbThird->hide();
    layout()->setSizeConstraint(QLayout::SetFixedSize);
    setColumnRange('A', 'Z');
    }

    void DialogExpand::setColumnRange(QChar first, QChar last)
    {
    ui->cbFirstColumn->clear();
    ui->cbSecColumn->clear();
    ui->cbSecColumn_2->clear();
    ui->cbFirstColumn->addItem(tr("None"));
    ui->cbSecColumn->addItem(tr("None"));
    ui->cbFirstColumn->setMinimumSize(
    ui->cbSecColumn->sizeHint());
    QChar ch = first;
    while (ch <= last) {
    ui->cbFirstColumn->addItem(QString(ch));
    ui->cbSecColumn->addItem(QString(ch));
    ui->cbSecColumn_2->addItem(QString(ch));
    ch = ch.unicode() + 1;
    }
    }@

    Edit: I found the answer "here":http://www.qtcentre.org/threads/51981-Shape-Changing-Dialog , just set the button more checkable

    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