c++ - How to make QGraphicsTextItem single line? -


i have qgraphicstextitem behave lineedit, using

settextinteractionflags(qt::texteditorinteraction); 

however show multiline if user presses enter. want ignore line wraps, how that?

afaik qgraphicstextitem doesn't implement functionality. can trick subclassing qgraphicstextitem , filter keyboard events:

class mygraphicstextitem : public qgraphicstextitem {  // ...  protected:      virtual void keypressevent(qkeyevent* e) overriden     {         if(e->key() != qt::key_return)         {             // let parent implementation handle event             qgraphicstextitem::keypressevent(event);         }         else         {             // ignore event , stop propagation             e->accept();         }     }  }; 

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -