New window -> Where are my buttons?

  • When I make new QMainWindow or QDialog, or any new window, my objects in "newwindow" don't see anywhere. I mean that when I press pushbutton, it shows new window, where should be few buttons and widgets, but here is, nothing.
    Why my buttons disappears? I tryed to write "ui->pushButton->show;", to "newwindow.cpp" but it doesn't help.

    @#include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include "newwindow.h"

    #include <QtCore/QCoreApplication>

    MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindow)

    delete ui;

    // there was lots of useless text, so I took it out for this answer.

    void MainWindow::on_pushButton_clicked()
    newwindow = new QMainWindow;

    @#ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QtGui/QMainWindow>
    #include "newwindow.h"

    namespace Ui {
    class MainWindow;

    class MainWindow : public QMainWindow

    // I think there was too lots of useless text, so I took it out for this answer too

    private slots:
    void on_pushButton_clicked();

    Ui::MainWindow *ui;
    QMainwindow *newwindow;

    #endif // MAINWINDOW_H

    Do you know what is the problem? Shoul I write something about that to the "newwindow.h" or "newwindow.cpp"
    Thank you!

  • Shouldn't you create an object of the type NewWindow (or the class name you defined in newwindow.h) instead of QMainWindow ?

  • Indeed. A QMainWindow does not have any content in it :-)

  • Thanks! You were right. I should use "NewWindow" instead of QMainWindow.
    Thanks again, this helps me a lot!!

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.