Frage

Porting VS2010 project in QT .

I guess, I wasn’t very clear with my earlier post so here I am explaining it again.

The issue is .. I have lots of sub Qdialog windows which when user click generates some messages. I want those messages to be on my QTablewidget of my main Application window. Now As suggested by some members that I should look how things have done in VS2010 and try to replicate same in QT . So Here is my design .. Please let me know your suggestion /criticism.

1) vs 2010 -> On Main application window in

MESSAGE_MAP

we have

ON_MESSAGE( WM_NOTICE, OnAddMessage )

where WM_NOTICE = WM_USER+1;

....................................................................................

Doing same in QT I need signal and slot . so Something like

connect( sender , SIGNAL(QtSingleApplication::messageReceived ( const QString &message )  ) , this , SLOT ( on_add_message( const QString & message ) );

now what should I replace here with

  • ‘sender’ ? , who will be the sender in my case ?
  • SIGNAL (QtSingleApplication::messageReceived ) is right ?
  • Slot — there is no issue here .. I can implement that code in which I will place the message in QTable widegt in sorting order.

........................................................................................................

2) Now if I look into inner QDialog windows source code of existing project which was developed in VC++ they have something like

void Message_information::add( const SMS& message )
{
//SMS is a  structure  and fields are SYSTEMTIME, Enum , CString
 CCriticalSection critical_section;
CSingleLock   lock( &critical_section, true );
messages_.insert( message ); // where messages_ is an object std::multiset

SendMessage( dialog_->m_hWnd, WM_MULTIBOXMESSAGE, 0, 0 );
}

Now doing same in Qt

v

oid Message_information::add( const SMS& message )
{
  QMutex mutex;
  mutex.lock();
messages_.insert( message ); // where messages_ is an object std::multiset

//SendMessage( dialog_->m_hWnd, WM_MULTIBOXMESSAGE, 0, 0 );
QtSingleApplication::sendMessage ( // send multiset values here   );

}
  • What paramemter should I Add in SendMessage?

  • IS infact sendMessage is correct function to call?

The ‘add’ function is being called somewhere else . I know this sounds duplicate of other questions and I have looked into the link provided my some members but I am sorry I couldn’t able to grasp much. — Any suggestion or criticism might help me .. hanks a lot for al the help

War es hilfreich?

Lösung

Forget about windows messages if you are just trying to send information between two QOjects. It is complete waste of time.

If you want just pass data from your custom QDialog to some QMainWindow with QTablewidget signal and slots should do the whole job. Just define signals for your QDialog emit them when necessary and create connection with respective slot in QMainWindow containing QTablewidget.

The only case when you should process windows messages your self in Qt is when you do something unusual or when communicating with code written in something else then qt (for example MFC) or some inter process communication.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top