2016-09-05 3 views
1

У меня есть следующий код:MouseArea предотвращает редактирование

import QtQuick 2.4 
import QtQuick.Controls 1.4 

ApplicationWindow 
{ 
    id: myWindow2 
    title: qsTr("test window") 
    x: 500 
    y: 200 
    width: 800 
    height: 600 
    visible: true 

    TextEdit 
    { 
     id: tEdit 

     anchors.fill: parent 

     MouseArea 
     { 
      anchors.fill: parent 
      cursorShape: Qt.IBeamCursor 
     } 
    } 
} 

Каким-то образом 'MouseArea' предотвращает 'TEdit' работать. Он меняет форму курсора. Как я могу изменить форму и работать «tEdit»?

ответ

2

Установка acceptedButtons в Qt.NoButton, кажется, работает:

import QtQuick 2.4 
import QtQuick.Controls 1.4 

ApplicationWindow { 
    id: myWindow2 
    x: 500 
    y: 200 
    width: 800 
    height: 600 
    visible: true 

    TextEdit { 
     id: tEdit 
     anchors.fill: parent 

     MouseArea { 
      anchors.fill: parent 
      cursorShape: Qt.IBeamCursor 
      acceptedButtons: Qt.NoButton 
     } 
    } 
} 

Обратите внимание, что выделение текста с помощью мыши все еще работает, вы просто должны установить его на истинный:

selectByMouse: true 
Смежные вопросы