Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 751419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:39:53+00:00 2026-05-14T14:39:53+00:00

I have two widgets defined as follows class mainWindow : public QWidget { Q_OBJECT

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T14:39:54+00:00Added an answer on May 14, 2026 at 2:39 pm

    By default a QWidget isn’t a window. If it is not a window and you specify a parent, it will be displayed inside the parent (so in your case it is probably hidden by other widgets inside your mainWindow).

    Look at windowFlags() too. Or you could make your SWindow inherit from QDialog, depending on what you use it for.

    As for calling a function on widget close : you could reimplement closeEvent().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two custom widgets (two classes based on QtGui.QWidget). In __init__ of QtGui.QMainWindow
I have two widgets that can be checked, and a numeric entry field that
I have two OptionMenu widgets in the simple pieces of code shown below: variable
I have two tables. One (Widgets) has a list of widgets (ID, widget_name, color,
I have two classes (MVC view model) which inherits from one abstract base class.
I have two widgets listening for a MouseOutEvent. Problem is that sometimes this events
I have two models related by a foreign key: # models.py class TestSource(models.Model): name
I have two widgets, one arbitrary (usually a QLineEdit), and one QLabel which displays
I have an object in C# like this: private ClassWidget { public int ID;
I have two JQuery widgets, one is a sort of 'main' widget, the other

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.