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. Problem with window/widget size
Forum Update on Monday, May 27th 2025

Problem with window/widget size

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 499 Views
  • 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.
  • N Offline
    N Offline
    never_ever
    wrote on 16 May 2014, 13:01 last edited by
    #1

    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

    1 Reply Last reply
    0

    1/1

    16 May 2014, 13:01

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved