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. Unsuccessfully post Event
Qt 6.11 is out! See what's new in the release blog

Unsuccessfully post Event

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 2.2k 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.
  • P Offline
    P Offline
    pmjz
    wrote on last edited by
    #1

    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
    0
    • Z Offline
      Z Offline
      Zarko Markovic
      wrote on last edited by
      #2

      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
      0
      • P Offline
        P Offline
        pmjz
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          Zarko Markovic
          wrote on last edited by
          #4

          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
          0
          • P Offline
            P Offline
            pmjz
            wrote on last edited by
            #5

            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
            0

            • Login

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