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.6k 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.
  • 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
                    • Christian EhrlicherC Offline
                      Christian EhrlicherC Offline
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on last edited by
                      #32

                      I still don't understand the need to know the size of a widget at all - your code you showed us doesn't do anything with it. Use layouts...

                      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
                      0
                      • JonBJ JonB

                        @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 Offline
                        C Offline
                        circle
                        wrote on last edited by circle
                        #33

                        @JonB
                        qDebug to print the line and ui->centralwidget->width()

                        JonBJ 1 Reply Last reply
                        0
                        • Christian EhrlicherC Christian Ehrlicher

                          I still don't understand the need to know the size of a widget at all - your code you showed us doesn't do anything with it. Use layouts...

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

                          @Christian-Ehrlicher
                          well, i am supposed to do some complicated drawings as the background based on the size of centralwidget, there maybe several different solutions and i never use layouts before. those code was migrated from windows.

                          1 Reply Last reply
                          0
                          • C circle

                            @JonB
                            qDebug to print the line and ui->centralwidget->width()

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

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

                            qDebug to print the line and ui->centralwidget->width()

                            Can you show just the few lines of code where you do this? What method it's in and where you do it.

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

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

                              i am supposed to do some complicated drawings as the background

                              You can't draw on a widget outside the paintEvent()...

                              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
                              1
                              • JonBJ JonB

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

                                qDebug to print the line and ui->centralwidget->width()

                                Can you show just the few lines of code where you do this? What method it's in and where you do it.

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

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

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

                                qDebug to print the line and ui->centralwidget->width()

                                Can you show just the few lines of code where you do this? What method it's in and where you do it.

                                void MainWindow::showEvent(QShowEvent * event)
                                {
                                    QMainWindow::showEvent(event);
                                    qDebug() << "w: " << ui->centralwidget->width() << "h: " << ui->centralwidget->height();
                                }
                                
                                1 Reply Last reply
                                1
                                • Christian EhrlicherC Christian Ehrlicher

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

                                  i am supposed to do some complicated drawings as the background

                                  You can't draw on a widget outside the paintEvent()...

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

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

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

                                  i am supposed to do some complicated drawings as the background

                                  You can't draw on a widget outside the paintEvent()...

                                  maybe paintEvent() is a better way, but i'm using eventFilter() instead (i am new to qt), more specifically, most of drawings are in the memory, such as qpixmap, qpainterpath, and they are working fine.

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

                                    But not in your example you show above - there you do a lot of stuff which doesn't belong to a resize (or paint)Event. I gave you a lot of examples on how to change it. Giving up.

                                    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
                                    1

                                    • Login

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