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. sometimes qt was ended forcefully, weird.
Forum Updated to NodeBB v4.3 + New Features

sometimes qt was ended forcefully, weird.

Scheduled Pinned Locked Moved Unsolved General and Desktop
39 Posts 6 Posters 4.7k 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #12

    Can you explain what kind of logic is required to be run in the resize event ?

    Typically I do not see why you would need to add a widget there.

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

    C 1 Reply Last reply
    2
    • SGaistS SGaist

      Can you explain what kind of logic is required to be run in the resize event ?

      Typically I do not see why you would need to add a widget there.

      C Offline
      C Offline
      circle
      wrote on last edited by
      #13

      @SGaist
      thanks for your time. my app is fullscreen always, and the main reason i do the initialization work in the resize event is, i need to know the size of the fullscreen, as a lot of drawing is based on this size. Most of the drawing is done in the memory, while the small part is done in paintEvent.
      where do you think i should do these things? showEvent?

      Pl45m4P 1 Reply Last reply
      0
      • C circle

        @SGaist
        thanks for your time. my app is fullscreen always, and the main reason i do the initialization work in the resize event is, i need to know the size of the fullscreen, as a lot of drawing is based on this size. Most of the drawing is done in the memory, while the small part is done in paintEvent.
        where do you think i should do these things? showEvent?

        Pl45m4P Offline
        Pl45m4P Offline
        Pl45m4
        wrote on last edited by Pl45m4
        #14

        @circle said in sometimes qt was ended forcefully, weird.:

        where do you think i should do these things?

        You can get the size (geometry) of your widget anywhere, without calling the stuff every time you resize.

        If you want to do something just once, consider doing it inside your c'tor or use the showEvent, when you need the actual size.
        (Your widget's size in c'tor and showEvent will / may be different, because of layouts)


        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

        C 1 Reply Last reply
        0
        • Pl45m4P Pl45m4

          @circle said in sometimes qt was ended forcefully, weird.:

          where do you think i should do these things?

          You can get the size (geometry) of your widget anywhere, without calling the stuff every time you resize.

          If you want to do something just once, consider doing it inside your c'tor or use the showEvent, when you need the actual size.
          (Your widget's size in c'tor and showEvent will / may be different, because of layouts)

          C Offline
          C Offline
          circle
          wrote on last edited by
          #15

          @Pl45m4 said in sometimes qt was ended forcefully, weird.:

          c'tor

          thanks, i tried to get the real fullscreen's size in the c'tor or in the showEvent, but the size was wrong. that's why i put those work in the resizeEvent and isVisible() block.

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

            @circle said in sometimes qt was ended forcefully, weird.:

            tried to get the real fullscreen's size in the c'tor

            QScreen doesn't work differently if it is called in the ctor or anywhere else.

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

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

              Depending on what you need, I would rather go with changeEvent and check the QEvent::WindowStateChange event. You will know there when the window is fullscreen.

              But again, doing stuff that depends on the specifics of being fullscreen is a bit surprising. Painting is usually done so that it does not directly depend on one specific size because even if fullscreen you may have different sizes.

              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
              • Christian EhrlicherC Christian Ehrlicher

                @circle said in sometimes qt was ended forcefully, weird.:

                tried to get the real fullscreen's size in the c'tor

                QScreen doesn't work differently if it is called in the ctor or anywhere else.

                C Offline
                C Offline
                circle
                wrote on last edited by
                #18

                @Christian-Ehrlicher
                more precisely, what i need is the size of centralwidget when it's fullscreen. so i just use the width() and hegith() to obtain those when it's fullscreen.
                i didn't use QScreen, should i?

                @SGaist
                there may be different ways to get the size, but i still don't have a clue why it produce such an error. it seems have nothing to do with the error, and why sometimes it's working, sometimes not.

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

                  @circle said in sometimes qt was ended forcefully, weird.:

                  i didn't use QScreen, should i?

                  I suggest you to use it so I would say it's worth a try reading the documentation, isn't it?

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

                  1 Reply Last reply
                  0
                  • C circle

                    @Christian-Ehrlicher
                    more precisely, what i need is the size of centralwidget when it's fullscreen. so i just use the width() and hegith() to obtain those when it's fullscreen.
                    i didn't use QScreen, should i?

                    @SGaist
                    there may be different ways to get the size, but i still don't have a clue why it produce such an error. it seems have nothing to do with the error, and why sometimes it's working, sometimes not.

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

                    @circle said in sometimes qt was ended forcefully, weird.:

                    more precisely, what i need is the size of centralwidget when it's fullscreen.

                    Then it doesn't sound like you should be looking at QScreen at all.

                    thanks, i tried to get the real fullscreen's size in the c'tor or in the showEvent,

                    To get a size of widget (not the full screen, which you shouldn't be interested in) correctly it needs to be shown. If you call it too early, you get rubbish. Constructor is not the place. If in a showEvent(), IIRC you should call the base showEvent() before you try to read the size.

                    C 1 Reply Last reply
                    0
                    • JonBJ JonB

                      @circle said in sometimes qt was ended forcefully, weird.:

                      more precisely, what i need is the size of centralwidget when it's fullscreen.

                      Then it doesn't sound like you should be looking at QScreen at all.

                      thanks, i tried to get the real fullscreen's size in the c'tor or in the showEvent,

                      To get a size of widget (not the full screen, which you shouldn't be interested in) correctly it needs to be shown. If you call it too early, you get rubbish. Constructor is not the place. If in a showEvent(), IIRC you should call the base showEvent() before you try to read the size.

                      C Offline
                      C Offline
                      circle
                      wrote on last edited by
                      #21

                      @JonB
                      even call the base showEvent() first, i still can't read the right size of the centralwidget.
                      anyway, the size is not a problem, the problem is that weird errors reported has nothing to do with the code as far as i am concerned.

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

                        @circle said in sometimes qt was ended forcefully, weird.:

                        i still can't read the right size of the centralwidget.

                        Again: use QScreen to determine the screen size!

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

                        JonBJ 1 Reply Last reply
                        0
                        • Christian EhrlicherC Christian Ehrlicher

                          @circle said in sometimes qt was ended forcefully, weird.:

                          i still can't read the right size of the centralwidget.

                          Again: use QScreen to determine the screen size!

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

                          @Christian-Ehrlicher
                          How will knowing the screen size help this user if he want to know the central widget size?

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

                            @JonB said in sometimes qt was ended forcefully, weird.:

                            if he want to know the central widget size?

                            my app is fullscreen always

                            so...

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

                            JonBJ 1 Reply Last reply
                            0
                            • Christian EhrlicherC Christian Ehrlicher

                              @JonB said in sometimes qt was ended forcefully, weird.:

                              if he want to know the central widget size?

                              my app is fullscreen always

                              so...

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

                              @Christian-Ehrlicher
                              So? :) The central widget is some widget in the full screen app, but there can be all sorts round the edges. So the widget itself won't be the full screen. I'm thinking like the central widget area in a QMainWindow. I guess you're not?

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

                                @JonB said in sometimes qt was ended forcefully, weird.:

                                I guess you're not?

                                I don't see a need for all the calculation at all - using a proper layout will make all those stuff superfluous.

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

                                JonBJ 1 Reply Last reply
                                1
                                • Christian EhrlicherC Christian Ehrlicher

                                  @JonB said in sometimes qt was ended forcefully, weird.:

                                  I guess you're not?

                                  I don't see a need for all the calculation at all - using a proper layout will make all those stuff superfluous.

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

                                  @Christian-Ehrlicher said in sometimes qt was ended forcefully, weird.:

                                  I don't see a need for all the calculation at all - using a proper layout will make all those stuff superfluous.

                                  I agree! But it wasn't the question :)

                                  1 Reply Last reply
                                  0
                                  • C Offline
                                    C Offline
                                    circle
                                    wrote on last edited by circle
                                    #28

                                    @all,
                                    thank you so much for your time. sorry i wasn't clear about my requirement. what i care is the centrawidget size when QMainWindow is in fullscreen.

                                    again, i am posting the code with the erros,

                                    MainWindow::MainWindow(QWidget *parent)
                                        : QMainWindow(parent)
                                        , ui(new Ui::MainWindow)
                                    {
                                        ui->setupUi(this);
                                        showFullScreen();
                                    
                                        ui->dockWidget->setWidget(ui->tableWidget);
                                    
                                        ui->line1->hide();
                                    }
                                    
                                    
                                    void MainWindow::resizeEvent(QResizeEvent *event)
                                    {
                                        QMainWindow::resizeEvent(event);
                                    
                                        // Your code here.
                                        static bool bOnlyOnce = true;
                                        if (bOnlyOnce && isVisible())
                                        {
                                            bOnlyOnce = false;
                                            
                                            memory allocation, file reading and data initialization
                                    
                                            QFileInfo fileInfo(QCoreApplication::applicationFilePath()); 
                                            if ()
                                                QMessageBox::information(this, "title", QString("%1").arg(fileInfo.size())); //***sometimes crash here ???
                                        
                                            get the size of centralwidget, prepare drawing environment
                                    
                                            ui->statusbar->addWidget(ui->lable1, 40); //***sometimes it crash here if i comment out QMessageBox line above*** ???
                                        }
                                    }
                                    

                                    now the QMessageBox line would crash sometimes(qtcreator says the process was ended forcefully), and if i comment out this line, the ui->statusbar line sometimes would report "Trying to construct an instance of an invalid type, type id: 1061" and the process was ended forcefully.
                                    i haven't found any rules about "sometimes", sometimes it will crash several times continuously when i press CTRL+R, but sometimes the program works fine.
                                    And it's working alwasys fine if i press F5 to debug the app.

                                    In addition, in the old backup version, it's working always fine. this version just has more functions after the crash point.

                                    1 Reply Last reply
                                    -3
                                    • Christian EhrlicherC Offline
                                      Christian EhrlicherC Offline
                                      Christian Ehrlicher
                                      Lifetime Qt Champion
                                      wrote on last edited by Christian Ehrlicher
                                      #29

                                      As @J-Hilk already told you 4 days ago - don't create an eventloop in a resize event!

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

                                      C 1 Reply Last reply
                                      3
                                      • Christian EhrlicherC Christian Ehrlicher

                                        As @J-Hilk already told you 4 days ago - don't create an eventloop in a resize event!

                                        C Offline
                                        C Offline
                                        circle
                                        wrote on last edited by
                                        #30

                                        @Christian-Ehrlicher
                                        thanks, i am not 100% sure about that answer, but i will try another solution. now the question is, where do i get the size of centralwidget automatically when QMainWindows is in fullscreen (showFullScreen() in c'tor)? i tried showEvent and C'tor but failed to get the right size.

                                        JonBJ 1 Reply Last reply
                                        0
                                        • C circle

                                          @Christian-Ehrlicher
                                          thanks, i am not 100% sure about that answer, but i will try another solution. now the question is, where do i get the size of centralwidget automatically when QMainWindows is in fullscreen (showFullScreen() in c'tor)? i tried showEvent and C'tor but failed to get the right size.

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

                                          @circle
                                          I admit I have not tried it but I would have expected it in showEvent() as we discussed earlier. Could you show where you put what code for that?

                                          C 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