Exemplo n.º 1
0
// if preformance would be critical, replace with QHash<QString userId, ChatPageWidget*>
ChatPageWidget* PagesWidget::widget(const QString& userId) const
{
    for (int i = 0; i < count(); i ++) {
        ChatPageWidget* chatPage = dynamic_cast<ChatPageWidget*>(QStackedWidget::widget(i));
        if (chatPage != nullptr && chatPage->getUserId() == userId) {
            return chatPage;
        }
    }
    return nullptr;
}
Exemplo n.º 2
0
void PagesWidget::onMessageSent(const QString &message)
{
    ChatPageWidget* chatPage = static_cast<ChatPageWidget*>(sender());
    emit messageSent(chatPage->getUserId(), message);
}