Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsuccessfully post Event

    General and Desktop
    2
    5
    1747
    Loading More Posts
    • 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
      pmjz last edited by

      Hi guys,

      I wanna post a QWheelEvent to QPlaintextEditor which is in a QVBoxLayout, but it does not work, I can not get that event. Welcome any ideas

      @ShowD::ShowD( QWidget *parent )
      : QDialog( parent )
      {
      // Disables the "?" What's This button from the dialog.
      setWindowFlags( Qt::Dialog | Qt::WindowTitleHint );

      setFocusPolicy( Qt::StrongFocus );

      // this dialog is built from code (no FORM [*.ui] file).
      resize( 700, 600 );

      setWindowTitle( tr( "Legal" ) );

      myVerticalLayout = new QVBoxLayout( this );
      myVerticalLayout->setContentsMargins( 6, 6, 6, 6 );

      myTextEdit = new QPlainTextEdit( this );

      // set editor to read-only (no editing allowed)
      myTextEdit->setReadOnly( true );
      myTextEdit->setEnabled( true );

      // add the text edit to the layout
      myVerticalLayout->addWidget( myTextEdit );
      }@

      @ QPoint pos = QPoint( 10, 10 );
      QApplication::postEvent( myTextEdit, new QWheelEvent( pos, 120, Qt::NoButton, Qt::NoModifier ) );
      @

      1 Reply Last reply Reply Quote 0
      • Z
        Zarko Markovic last edited by

        Install event filter for myTextEdit, no need to post events. Read more on "QObject::installEventFilter":http://qt-project.org/doc/QObject.html#installEventFilter

        1 Reply Last reply Reply Quote 0
        • P
          pmjz last edited by

          thank you for advice, If I wanna postEvent, How should I do?

          1 Reply Last reply Reply Quote 0
          • Z
            Zarko Markovic last edited by

            Sorry it seems I misunderstood your question. If you want to control the scroll bar position you can just do this:
            @QScrollBar *tQScrollBar = myTextEdit->verticalScrollBar();
            tQScrollBar->setValue(120);@

            Or maybe your intention is something else..

            1 Reply Last reply Reply Quote 0
            • P
              pmjz last edited by

              thanks. but my basic idea is to simulate a wheel Event as soon as something happen. post QWheelEvent is one of my choose. I have no idea what is wrong with my code above? welcome any other talent.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post