Problem with window/widget size



  • Hi,
    I have mainWindow (that inherits by QMainWindow), and I have second class that inherits by QWidget and it is invoked by first class.
    In second window I have QGraphicsView. In second class I need to use QGraphicsView size (ui.graphicsView()->size()), but this size depends on the place where I write

    @
    secondWindow = new SecondWindow();
    @

    mainwindow.cpp

    @
    MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    {
    ui.setupUi(this);
    connect(ui.pbOpenFile, SIGNAL(clicked()),
    this, SLOT(addFile()));

    //first way/place
    newWindow = new MyClass();
    }

    void MainWindow::addFile()
    {
    this->hide();
    fileName = QFileDialog::getOpenFileName(this,
    tr("Open file"), QDir::homePath(), tr("File TXT (*txt)"));

    if(!fileName.isEmpty())
    {
    //second way
    //newWindow = new MyClass();
    /*
    ...
    */
    }
    else
    this->show();
    }
    @

    myclass.cpp

    @
    MyClass::MyClass(QWidget parent)
    : QWidget(parent)
    {
    ui.setupUi(this);
    showMaximized()
    /

    ...
    */
    }
    @

    When I write it in first place the second window shows before I choose file to open and I don't want that. I want that it will open after I choose the file. But when I write it in second place I get wrong size of QGraphicsView widget (size of not maximized window).
    Any idea why it happens in that way? Maybe I


Log in to reply
 

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