Qt, can't display child widget

Posted by Blin on Stack Overflow See other posts from Stack Overflow or by Blin
Published on 2010-04-22T21:54:10Z Indexed on 2010/04/22 22:13 UTC
Read the original article Hit count: 217

Filed under:
|
|

I have two widgets defined as follows

class mainWindow : public QWidget
{
    Q_OBJECT
public:
    mainWindow();
    void readConfig();
private:
    SWindow *config;
    QVector <QString> filePath;
    QVector <QLabel*> alias,procStatus;
    QVector <int> delay;
    QGridLayout *mainLayout;
    QVector<QPushButton*> stopButton,restartButton;
    QVector<QProcess*> proc;
    QSignalMapper *stateSignalMapper, *stopSignalMapper, *restartSignalMapper;
public slots:
    void openSettings();
    void startRunning();
    void statusChange(int);
    void stopProc(int);
    void restartProc(int);
    void renew();
};
class SWindow : public QWidget
{
    Q_OBJECT
public:
    SWindow(QWidget *parent=0);
    void readConfig();
    void addLine(int);
private:
    QVector<QPushButton*> selectButton;
    QVector<QLabel*> filePath;
    QVector<QLineEdit*> alias;
    QSignalMapper *selectSignalMapper;
    QVector<QSpinBox*> delay;
    QGridLayout *mainLayout;
public slots:
    void selectFile(int);
    void saveFile();
    void addLineSlot();
};

when i create and display SWindow object from mainWindow like this

void mainWindow::openSettings()
{
    config = new SWindow();
    config->show();
}

everything is ok, but now i need to access the mainWindow from SWindow, and

void mainWindow::openSettings()
{
    config = new SWindow(this);
    config->show();
}

doesn't display SWindow. How can i display SWindow?

How do i call a function on widget close?

© Stack Overflow or respective owner

Related posts about qt

Related posts about c++