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. How to conditionally drag a QSplitter handle

How to conditionally drag a QSplitter handle

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 4.4k Views 1 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.
  • J Offline
    J Offline
    julio jerez
    wrote on last edited by
    #1

    Hi I have a four way Pane graphic viewport, and each pain has an action for maximize it and minimize it.
    When I maximize the splitter, they have a bool that indicate whet that viewport is minimize or not.

    It all work very well with the exception that QT allows to drag the splitter handler even when they are all collapsed,
    Basically I want to trap the even that move the splitter handle and reject test if any of the tow children is maximized, if it is the even should be consume as do nothing

    I see the splitter class has these four special events, but nine of them is called when dragging the handle.

    @virtual void changeEvent ( QEvent * ev )
    virtual void childEvent ( QChildEvent * c )
    virtual bool event ( QEvent * e )
    virtual void resizeEvent ( QResizeEvent * )@

    Can someone please tell me how to intersect, the Dragging handle event before it do the operation?

    1 Reply Last reply
    0
    • N Offline
      N Offline
      novaktamas
      wrote on last edited by
      #2

      Subclass the QSplitter to your own. You can find the possible virtual eventhadlers in "qt/src/gui/widgets/qsplitter.h"

      @class YourOwn : public QSplitter {
      Q_OBJECT;
      public:
      YourOwn(QWidget* parent = NULL);
      protected:
      virtual void mouseMoveEvent(QMouseEvent *);
      virtual void mousePressEvent(QMouseEvent *);
      virtual void mouseReleaseEvent(QMouseEvent *);
      virtual void resizeEvent(QResizeEvent *);
      };

      void YourOwn::mouseMoveEvent(QMouseEvent *ev) {
      <do what you want> //To make the mouse move effective, you may call original handler
      QSplitter::mouseMoveEvent(ev);
      }
      @
      If subclass is ready, change your QSplitter object on the from to YourOwn class with the "Promote" command (UI -right mouse click - Promote..)

      I hope this helps. It took some days for me to see this clearly... thanks redirected to "peppe" and "ivan.todorovich":))

      1 Reply Last reply
      0
      • J Offline
        J Offline
        julio jerez
        wrote on last edited by
        #3

        well I just added this

        @class alchemediaCanvas: public QSplitter
        {
        public:
        alchemediaCanvas(QWidget* const parent);
        ~alchemediaCanvas(void);

        void mouseMoveEvent(QMouseEvent *ev)
        {
        QSplitter::mouseMoveEvent(ev);
        }

        alchemediaVerticalSpliter* m_leftPane;
        alchemediaVerticalSpliter* m_rightPane;
        QByteArray m_maximizedState;
        };@

        But that does not really does it.
        I set a break point on the function, and it hit the break point if I click on the toolbar, but not when I click on the handle, I need it when I click the handle.

        there has to be a way to do this, bu I cannot figure it out.

        1 Reply Last reply
        0
        • J Offline
          J Offline
          julio jerez
          wrote on last edited by
          #4

          Oh I see, your suggestion showed me how to do it.
          There is a method called createHandle,
          So instead of overwriting mouseMoveEvent on the spliter I oveloaded createHandle to create my own QSplitterHandle and on the class I overload
          mouseMoveEvent, and it worked like a cham
          here are the classes, in case you wonder
          @class alchemediaCanvas: public QSplitter
          {
          public:
          alchemediaCanvas(QWidget* const parent);
          ~alchemediaCanvas(void);

          QSplitterHandle *createHandle()
          {
          return new alchemediaSplietHandle (Qt::Horizontal, this);
          }

          }

          class alchemediaSplietHandle: public QSplitterHandle
          {
          public:
          alchemediaSplietHandle(Qt::Orientation o, QSplitter *parent)
          :QSplitterHandle (o, parent)
          {

          }

          void mouseMoveEvent(QMouseEvent *ev)
          {
          // do my conditional move here.
          }
          };@

          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