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

javascript - How do you prevent nested queries/catches in sequelize? -

java - Could not retrieve pre-bound Hibernate session - Could not obtain transaction-synchronized Session for current thread -

java - ConcurrentModificationException upon committing transaction with Hibernate -