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. New window -> Where are my buttons?
Forum Updated to NodeBB v4.3 + New Features

New window -> Where are my buttons?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.0k 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.
  • M Offline
    M Offline
    Miikukka
    wrote on last edited by
    #1

    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.

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

    #include <QtCore/QCoreApplication>

    MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    }

    MainWindow::~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;
    newwindow->show();
    }
    @
    and

    mainwindow.h
    @#ifndef MAINWINDOW_H
    #define MAINWINDOW_H

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

    namespace Ui {
    class MainWindow;
    }

    class MainWindow : public QMainWindow
    {
    Q_OBJECT

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

    private slots:
    void on_pushButton_clicked();

    private:
    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!

    There are no stupid questions, only stupid answers.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      alexisdm
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on last edited by
        #3

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

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • M Offline
          M Offline
          Miikukka
          wrote on last edited by
          #4

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

          There are no stupid questions, only stupid answers.

          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