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. [SOLVED] Cast event when window size is changed

[SOLVED] Cast event when window size is changed

Scheduled Pinned Locked Moved General and Desktop
maximize
14 Posts 2 Posters 6.8k 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.
  • P p3c0
    16 Apr 2015, 07:56

    @Bremenpl With cast an event what do you mean by it ? What are you trying to achieve ? Can you post more details ? Looking at code it seems you are trying to move some widget.
    Also please use ``` (3 backticks) for posting code blocks.

    B Offline
    B Offline
    Bremenpl
    wrote on 16 Apr 2015, 08:00 last edited by
    #5

    @p3c0
    Sorry for the formating. yes, I am trying to move a widget (UndoView) when the MainWindow is resized.

    lprzenioslo.zut.edu.pl

    P 1 Reply Last reply 16 Apr 2015, 08:49
    0
    • B Bremenpl
      16 Apr 2015, 08:00

      @p3c0
      Sorry for the formating. yes, I am trying to move a widget (UndoView) when the MainWindow is resized.

      P Offline
      P Offline
      p3c0
      Moderators
      wrote on 16 Apr 2015, 08:49 last edited by
      #6

      @Bremenpl And what is UndoView ? What type ?

      157

      B 1 Reply Last reply 16 Apr 2015, 08:49
      0
      • P p3c0
        16 Apr 2015, 08:49

        @Bremenpl And what is UndoView ? What type ?

        B Offline
        B Offline
        Bremenpl
        wrote on 16 Apr 2015, 08:49 last edited by
        #7

        @p3c0
        Its something I am trying to implement from here http://docs.knobbits.org/qt4/tools-undoframework.html#mainwindow-class-definition

        lprzenioslo.zut.edu.pl

        P 1 Reply Last reply 16 Apr 2015, 09:01
        0
        • B Bremenpl
          16 Apr 2015, 08:49

          @p3c0
          Its something I am trying to implement from here http://docs.knobbits.org/qt4/tools-undoframework.html#mainwindow-class-definition

          P Offline
          P Offline
          p3c0
          Moderators
          wrote on 16 Apr 2015, 09:01 last edited by
          #8

          @Bremenpl If you want to some it in accordance with the MainWindow that you can get width and height from QResizeEvent and move the QUndoView. Something like

          void MainWindow::resizeEvent(QResizeEvent *e)
          {
              undoView->move(e->size().width(),undoView->y());
          }
          

          This will move undoView on x axis as mainwindow resize. Add some more calculation as per your requirement.

          157

          B 1 Reply Last reply 16 Apr 2015, 09:05
          0
          • P p3c0
            16 Apr 2015, 09:01

            @Bremenpl If you want to some it in accordance with the MainWindow that you can get width and height from QResizeEvent and move the QUndoView. Something like

            void MainWindow::resizeEvent(QResizeEvent *e)
            {
                undoView->move(e->size().width(),undoView->y());
            }
            

            This will move undoView on x axis as mainwindow resize. Add some more calculation as per your requirement.

            B Offline
            B Offline
            Bremenpl
            wrote on 16 Apr 2015, 09:05 last edited by Bremenpl
            #9

            @p3c0
            Accesing undoView in resizeEvent scope causes segmentation fault, thats the problem.

            lprzenioslo.zut.edu.pl

            P 1 Reply Last reply 16 Apr 2015, 09:07
            0
            • B Bremenpl
              16 Apr 2015, 09:05

              @p3c0
              Accesing undoView in resizeEvent scope causes segmentation fault, thats the problem.

              P Offline
              P Offline
              p3c0
              Moderators
              wrote on 16 Apr 2015, 09:07 last edited by p3c0
              #10

              @Bremenpl Ok. So is undoView initialized before using it ?

              157

              B 1 Reply Last reply 16 Apr 2015, 09:11
              0
              • P p3c0
                16 Apr 2015, 09:07

                @Bremenpl Ok. So is undoView initialized before using it ?

                B Offline
                B Offline
                Bremenpl
                wrote on 16 Apr 2015, 09:11 last edited by
                #11

                @p3c0
                Theres an initialisation of the pointer in the class header:

                QUndoView *undoView;
                

                Then In the mainwindow constructor I am running:

                undoStack = new QUndoStack(this);
                undoView = new QUndoView(undoStack);
                undoView->setWindowTitle(tr("Command List"));
                undoView->setWindowFlags(Qt::WindowStaysOnTopHint);
                undoView->setAttribute(Qt::WA_QuitOnClose, false);
                undoView->show();
                
                moveUndoView(); // PLEASE NOTE THAT THIS WORKS IN HERE, NO SEGFAULTS
                

                lprzenioslo.zut.edu.pl

                P 1 Reply Last reply 16 Apr 2015, 09:20
                0
                • B Bremenpl
                  16 Apr 2015, 09:11

                  @p3c0
                  Theres an initialisation of the pointer in the class header:

                  QUndoView *undoView;
                  

                  Then In the mainwindow constructor I am running:

                  undoStack = new QUndoStack(this);
                  undoView = new QUndoView(undoStack);
                  undoView->setWindowTitle(tr("Command List"));
                  undoView->setWindowFlags(Qt::WindowStaysOnTopHint);
                  undoView->setAttribute(Qt::WA_QuitOnClose, false);
                  undoView->show();
                  
                  moveUndoView(); // PLEASE NOTE THAT THIS WORKS IN HERE, NO SEGFAULTS
                  
                  P Offline
                  P Offline
                  p3c0
                  Moderators
                  wrote on 16 Apr 2015, 09:20 last edited by
                  #12

                  @Bremenpl Does it crash when you attempt to resize manually or as soon as you execute the application ? Because resize event will be fired at application startup too. Make sure undoView was initialized prior to this first resize event.

                  157

                  B 1 Reply Last reply 16 Apr 2015, 09:29
                  1
                  • P p3c0
                    16 Apr 2015, 09:20

                    @Bremenpl Does it crash when you attempt to resize manually or as soon as you execute the application ? Because resize event will be fired at application startup too. Make sure undoView was initialized prior to this first resize event.

                    B Offline
                    B Offline
                    Bremenpl
                    wrote on 16 Apr 2015, 09:29 last edited by Bremenpl
                    #13

                    @p3c0
                    You are right, that is the problem. The thing is, that I cant really create this object before i execute this->show() (MainWindow), because the program crashes as well.

                    Edit: undoStack and undoView had to be both declared before ui is build, I have forgot about that one. Now everything works, thank you a lot for help!

                    lprzenioslo.zut.edu.pl

                    P 1 Reply Last reply 16 Apr 2015, 09:45
                    0
                    • B Bremenpl
                      16 Apr 2015, 09:29

                      @p3c0
                      You are right, that is the problem. The thing is, that I cant really create this object before i execute this->show() (MainWindow), because the program crashes as well.

                      Edit: undoStack and undoView had to be both declared before ui is build, I have forgot about that one. Now everything works, thank you a lot for help!

                      P Offline
                      P Offline
                      p3c0
                      Moderators
                      wrote on 16 Apr 2015, 09:45 last edited by
                      #14

                      @Bremenpl You're Welcome :) You can mark the post as solved by editing the post title and prepending [Solved].
                      Happy Coding..

                      157

                      1 Reply Last reply
                      0

                      14/14

                      16 Apr 2015, 09:45

                      • Login

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