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. Second Window doesnt open properly while executing it displays and the fraction of seconds its again closed
Qt 6.11 is out! See what's new in the release blog

Second Window doesnt open properly while executing it displays and the fraction of seconds its again closed

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 3 Posters 1.3k 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.
  • sankarapandiyanS Offline
    sankarapandiyanS Offline
    sankarapandiyan
    wrote on last edited by sankarapandiyan
    #1

    I have the Warning message like this
    QWidget::setLayout: Attempting to set QLayout "" on MainWindow "MainWindow", which already has a layout

    JonBJ 1 Reply Last reply
    0
    • sankarapandiyanS sankarapandiyan

      I have the Warning message like this
      QWidget::setLayout: Attempting to set QLayout "" on MainWindow "MainWindow", which already has a layout

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @sankarapandiyan
      For the error message, a QMainWindow already has a layout, you're duplicating that with your setLayout(layout1);. Try using the existing QMainWindow::layout().

      Do the popup_progress->setMaximum(10); before the popupPB->start(1000);.

      I don't understand why you are going timer->stop(); as soon as you start it? For what you want, the stop() should be in SetValueProgress() when it has reached the maximum.

      I don't understand why you have 2 QTimers. Again, from our discussion of this in your other thread you should only have one timer.

      I don't know how all this related to your thread title, but start by getting the code all right and have a look again from there.

      Incidentally, I don't know whether you want to display your progress bar on the main window, but be aware that Qt has a https://doc.qt.io/qt-5/qprogressdialog.html QProgressDialog class, which pops up a separate dialog with a progress bar. This is the way many people would handle a progress bar.

      sankarapandiyanS 1 Reply Last reply
      3
      • JonBJ JonB

        @sankarapandiyan
        For the error message, a QMainWindow already has a layout, you're duplicating that with your setLayout(layout1);. Try using the existing QMainWindow::layout().

        Do the popup_progress->setMaximum(10); before the popupPB->start(1000);.

        I don't understand why you are going timer->stop(); as soon as you start it? For what you want, the stop() should be in SetValueProgress() when it has reached the maximum.

        I don't understand why you have 2 QTimers. Again, from our discussion of this in your other thread you should only have one timer.

        I don't know how all this related to your thread title, but start by getting the code all right and have a look again from there.

        Incidentally, I don't know whether you want to display your progress bar on the main window, but be aware that Qt has a https://doc.qt.io/qt-5/qprogressdialog.html QProgressDialog class, which pops up a separate dialog with a progress bar. This is the way many people would handle a progress bar.

        sankarapandiyanS Offline
        sankarapandiyanS Offline
        sankarapandiyan
        wrote on last edited by
        #3

        @JonB No I want to display on another Window

        JonBJ 1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @sankarapandiyan said in Second Window doesnt open properly while executing it displays and the fraction of seconds its again closed:

          setLayout(layout1);

          Here you definitly try to set the created layout to the current window - this is what @JonB said above. If you want another dialog, create a new QDialog or QWidget

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          sankarapandiyanS 1 Reply Last reply
          1
          • sankarapandiyanS sankarapandiyan

            @JonB No I want to display on another Window

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #5

            @sankarapandiyan said in Second Window doesnt open properly while executing it displays and the fraction of seconds its again closed:

            @JonB No I want to display on another Window

            It would be really nice if you tried following the whole load of suggestion instead of just this answer...

            And if you do want to "display on another Window" did you think about the QProgressDialog?

            sankarapandiyanS 1 Reply Last reply
            1
            • JonBJ JonB

              @sankarapandiyan said in Second Window doesnt open properly while executing it displays and the fraction of seconds its again closed:

              @JonB No I want to display on another Window

              It would be really nice if you tried following the whole load of suggestion instead of just this answer...

              And if you do want to "display on another Window" did you think about the QProgressDialog?

              sankarapandiyanS Offline
              sankarapandiyanS Offline
              sankarapandiyan
              wrote on last edited by sankarapandiyan
              #6
              This post is deleted!
              JonBJ 1 Reply Last reply
              0
              • Christian EhrlicherC Christian Ehrlicher

                @sankarapandiyan said in Second Window doesnt open properly while executing it displays and the fraction of seconds its again closed:

                setLayout(layout1);

                Here you definitly try to set the created layout to the current window - this is what @JonB said above. If you want another dialog, create a new QDialog or QWidget

                sankarapandiyanS Offline
                sankarapandiyanS Offline
                sankarapandiyan
                wrote on last edited by
                #7

                @Christian-Ehrlicher sure thanks

                1 Reply Last reply
                0
                • sankarapandiyanS sankarapandiyan

                  This post is deleted!

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by
                  #8

                  @sankarapandiyan said in Second Window doesnt open properly while executing it displays and the fraction of seconds its again closed:

                  Yes i know , we dnt want a another window its automatically created
                  QProgressdialog

                  Fair enough. Ignore that bit, but start by changing code as per the other suggestions.

                  sankarapandiyanS 1 Reply Last reply
                  0
                  • JonBJ JonB

                    @sankarapandiyan said in Second Window doesnt open properly while executing it displays and the fraction of seconds its again closed:

                    Yes i know , we dnt want a another window its automatically created
                    QProgressdialog

                    Fair enough. Ignore that bit, but start by changing code as per the other suggestions.

                    sankarapandiyanS Offline
                    sankarapandiyanS Offline
                    sankarapandiyan
                    wrote on last edited by
                    #9

                    @JonB Sure thanks for your words

                    1 Reply Last reply
                    1

                    • Login

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