How can I make the child window button respond to the slot function on the parent window? Very anxio

Updated on technology 2024-02-09
8 answers
  1. Anonymous users2024-02-06

    You mean that a button in the child window is clicked, and a slot function on the parent window responds to the click, right?

    It's very simple: 1) Add a signal to the child window, and add a response slot to the parent window to receive this signal.

    2) emit this signal in the slot function of the button of the subwindow.

    3) Connect the signal of the child window to your own response slot in the parent window.

    Child window. class childwindow : public qwidget

    q_object

    public:

    childwindow(qwidget* p = 0)

    qwidget(p)

    qvboxlayout* l = new qvboxlayout(this);

    qpushbutton* btn = new qpushbutton("btn", this);

    l->addwidget(btn);

    connect(btn, signal(clicked())slot(clickedbtn())

    signals:

    This signal is sent to the parent window.

    void childwindowevent();

    protected slots:

    Click the slot button in the subwindow

    void clickedbtn()

    The signal that triggers the child window is received by the parent window.

    emit childwindowevent();

    Parent window. class parentwindow : public qwidget

    q_object

    public:

    parentwindow(qwidget* p = 0)

    qwidget(p)

    qvboxlayout* l = new qvboxlayout(this);

    w = new childwindow(this);

    l->addwidget(w);

    Connect the signal of the child window to the parent window.

    connect(w, signal(childwindowevent())slot(childwindoweventslot())

    protected:

    childwindow* w;

    protected slots:

    The slot used by the parent window to receive signals from the child window.

    void childwindoweventslot()

    The button for the subwindow was clicked.

  2. Anonymous users2024-02-05

    What do you mean? Have the child window button respond to the slot function on the parent window.

  3. Anonymous users2024-02-04

    You can use exec() directly to display the form.

    You can also setModel(true) first; Then in show(); to display.

  4. Anonymous users2024-02-03

    Let's say the main window is w

    The sub-window is d after clicking w->hide

    d->show

  5. Anonymous users2024-02-02

    a a in the parent window; Child window.

    Child window. emit xinhao(qstring...

  6. Anonymous users2024-02-01

    If you just can't press any buttons, just set enable(false) all the buttons of the parent window when the child window is open. The specific implementation is not too complicated, and you can definitely do macro model digging. Of course, if the child window inherits from qwidget, then the parent can be set directly as the main window in the build timecode.

  7. Anonymous users2024-01-31

    The ability to express oneself is limited, and the landlord's mailbox is pasted to give you the program.

  8. Anonymous users2024-01-30

    It's a very simple program, LZ writes it yourself......

    Roughly as follows: first customize a class, inherited from qwidget, this class has qpushbutton, qlineedit two subcomponents, and then customize a slot function to modify qlineedit Chinese content, and then use a connect to connect the clicked() signal of qpushbutton with the custom slot.

Related questions
12 answers2024-02-09

Nothing is absolute.

Feelings are no exception. >>>More

16 answers2024-02-09

1. Magical cartons.

How to play: Leave the tissue box used at home, put some toys, candies, fruits, etc. into it, let the baby touch it, ask him to say the name before taking it out, or give him instructions, ask him to take out things according to the instructions. For older children, you can give them negative instructions, such as: >>>More

2 answers2024-02-09

I myself have a very simple practice of life and death: every day when I go to bed, I think, "If I fall asleep today, I won't get up again tomorrow." If you think about it this way, you can sleep well, because when you think that tomorrow there will be nothing to disturb me, you will let go of all the sorrows of today, and even all the sorrows of the past, and you will not have any worries about the world, and you will not think that someone owes me 10,000 yuan, and I will take a taxi to ask him for 10,000 yuan, and what will I do when I come back with 10,000 yuan? >>>More

34 answers2024-02-09

Looks like you're on pretty good terms.

Short hair has very strict requirements for the shape of the face, and you can try cutting it shorter to make a very delicate semi-circular arc (not too rigid). >>>More

8 answers2024-02-09

This has nothing to do with your home computer configuration.,The configuration is only hooked with FPS.,I don't know how your home network speed is.,But if your home's ping is high.,At least the process of pulling the network speed is over.,It's always better.。