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. Hidden and Window
Forum Updated to NodeBB v4.3 + New Features

Hidden and Window

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 470 Views 2 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.
  • G Offline
    G Offline
    Gtivs
    wrote on last edited by
    #1

    I want to make switching between windows ..

    Made it through

    void BlitzerMainWindow::on_pushButton_clicked()
    {
        hide();
        homewindow = new HomeWindow(this, ui->textEdit_2->toPlainText());
        homewindow->show();
    }
    

    But after * Hidden *
    applications disappeared completely with TaskBar
    And a new window didn’t appear there either.

    So here is what to do?
    I want to create a new window so that it is in the taskbar

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #3

      Hi and welcome
      Adding to @SGaist,
      What is HomeWindow inherited from ?

      If its just a QWidget, then when you give it a parent it will get inserted into the parent and not act as a window

      homewindow = new HomeWindow(this<<<< parent , ui->textEdit_2->toPlainText());

      1 Reply Last reply
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi and welcome to devnet,

        This type of question has been asked pretty frequently these past few weeks. Please take the time to search the forum.

        As for your problem, you are closing the one and only window of your application which by default means that the application has ended.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        2
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #3

          Hi and welcome
          Adding to @SGaist,
          What is HomeWindow inherited from ?

          If its just a QWidget, then when you give it a parent it will get inserted into the parent and not act as a window

          homewindow = new HomeWindow(this<<<< parent , ui->textEdit_2->toPlainText());

          1 Reply Last reply
          1
          • G Offline
            G Offline
            Gtivs
            wrote on last edited by Gtivs
            #4

            I want to open a new window

            See task bar this

            48df4671-cdf4-4d68-ae2e-3da196adec39-изображение.png
            How to open a new window normally ..

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #5

              Like we already said and as already suggested in other threads: do not hide the main window before opening your new widget.

              And as @mrjj wrote, if you make your new widget a child of BlizterWindow, it will get hidden with it and thus the application will end so don't do that.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1
              • G Offline
                G Offline
                Gtivs
                wrote on last edited by Gtivs
                #6

                Sorry))

                I'm just too dumb and new to c ++ and qt

                Thanks for helping

                I replace this

                homewindow = new HomeWindow(this, ui->textEdit_2->toPlainText());
                

                On

                homewindow = new HomeWindow(nullptr, ui->textEdit_2->toPlainText());
                
                hide(); //i left this, since I wanted to hide the old window
                

                big thx @mrjj

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #7

                  In that case, please take the time to learn the C++ basics before taking on more complex tasks. It will save you a lot of time in the future.

                  The same goes for Qt, don't hesitate to go through the documentation. There are lots of tutorials and examples that can help you get started.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  1
                  • mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #8

                    Hi
                    No need to be sorry. Just ask good questions with
                    lots of details and the current code and we try to help. :)

                    However, as @SGaist says, using the Qt framework does demand some c++
                    skills as extending a class use inheritance and overrides of virtual functions
                    so its really up the hill if such concepts are unfamiliar.

                    Regarding this parent thing.
                    When you do give them a parent to a Widget, (to put it in another Widget)
                    it will then own the widget.
                    That means it will auto delete its children when its self is deleted.
                    This is unlike plain c++ where you must always remember to clean up allocated objects.
                    So this is a must-read.
                    https://doc.qt.io/qt-5/objecttrees.html

                    As not to delete something manually when its owned by another Widget/window
                    as that often gives a crash.

                    Now back to your window.
                    Every time you click the button , you create a new window.
                    So that will actually leak memory since it doesn't have a parent. ( to be a window)
                    You can do
                    homewindow ->setAttribute(Qt::WA_DeleteOnClose);
                    to have it delete itself when close so its cleaned up.

                    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