Qt: Best control for displaying chat messages - c++

I have been trying to use a textBrowser in order to display chat messages in my application. I've set the textBrowser with HTML enabled. I'm then appending each message to the textBrowser like so:
ui->textBrowser->append(QString().sprintf("<div style=\"border-bottom:1px solid #eeeeee; background-color:#ffffff;display:block;\"><font color=\"red\"> %s</font></div>",msg.toStdString().c_str()));
However, I am limited in what CSS i can apply to each appended element. For example;
- Border does not work
- Display block does not work
- etc.
I'm now fairly certain that the textBrowser just does not have the power that i need, I'm aiming in creating a chat message much like Skype is doing it.
What would be the best control to use for this purpose?
Some ideas I have so far:
- Use a scrollArea and append widgets inside of them
- Use a listView (not sure if its possible to style it the way i want)
Key elements i want to include in each chat message are:
- Time
- Avatar picture
- Name
- Text message
Any ideas what the best approach would be here?
Edit
Unfortunately i cant attach an image yet since I'm still new here.

I think you could simply use the WebKit (WebView) component. That will allow you to do anything you need and more. Styling and layout is done like a regular HTML/CSS page, then you can integrate it to the application backend via JavaScript.

Related

How to change WebBrowser fullscreen video mode?

I have a c++ project with 2 WeBBrowser in a TableLayoutPanel they are set side by side, it's working fine I navigate normal but when I go to specific websites and play a video in fullscreen that sets my whole monitor to fullscreen instead of setting only the WeBBrowser itself, however on other websites that fits perfect in the WeBBrowser. Is there a way to change the way it displays fullscreen? I wanna make it display fullscreen in the WeB​Browser only. I think it has something to do with Web​Browser​Base.​Active​XInstance Property or Web​Browser.​Document Property. Most examples I find on the internet is for the old VB and not related to the fullscreen property.
Here's a similar question:
WebBrowser control video element enter fullscreen
In other examples I've seen a method to extract the element by doing:
HtmlElement^ object = webBrowser1->Document->GetElementById("video");
But I have no idea how to handle that code in order to format that video then set it back to the WeBBrowser with fullscreen mode fixed.
EDIT:
I went further and I could get the <video> element just from a few websites, here's my method:
private: System::Void webBrowser1_DocumentCompleted(System::Object^ sender, System::Windows::Forms::WebBrowserDocumentCompletedEventArgs^ e) {
HtmlElementCollection^ videoElements = webBrowser1->Document->GetElementsByTagName("video");
videoElements[0]->SetAttribute("style", "width: 640px; height: 480px;"); //Not sure if this is a proper way to set an attribute in this element.
}
The problem is that not every website gives you access to <video> tag elements, so for those websites I did the following code to make sure there were indeed no <video> tag elements in the source:
System::Diagnostics::Debug::Write(webBrowser1->DocumentText);
Then I didn't find any <video> tag element in the output, only a few websites provide me that. Why? How to really get and manipulate properly <video> tag elements in c++?
Then I didn't find any tag element in the output, only a few websites provide me that. Why?
Let me make an educated guess. For some of the pages you're referring to, the DOM is built dynamically and asynchronously. Which means, those <video> tags might simply not be there yet.
So, you might need to have some asynchronous polling logic in place that monitors DOM changes, specifically looking for <video> tags.
It might not be possible to come up with a 100% working solution to cover all cases, but have a look at my other post which deals with this problem.

Sitecore Glass Mapper - Using Item Renderings

I'm setting up a carousel in Sitecore using Glass Mapper. In the foreach loop to generate each carousel item, I can get the items out easily enough and make them editable with the #Editable command. What this doesn't give, however, is finer control over the edit process. For example, I want to edit the background image using a custom button in the Experience Editor, but I need to set that up in a rendering.
If I was using straight Sitecore, it looks like I'd use Html.Sitecore().ItemRendering and pass in the carousel item as a regular Sitecore item. In this case, I have my strongly-type class from Glass Mapper, which can't be passed in that way.
Is there a comparable method in Glass Mapper for setting up an item rendering? Or is there another way to affect the Experience Editor buttons for the carousel items? I've also experimented with setting up a separate edit mode, which would work fine, but I wanted to put together a cleaner editing experience with a more WYSIWYG approach to the item.
You'll have to use Custom User Experience Buttons which will allow you to edit in Page Editor Mode.
I just googled and found couple of good article which might help you.
http://www.nishtechinc.com/Blog/2015/March/A%20Better%20Approach%20at%20Carousel%20Management
http://www.awareweb.com/awareblog/11-25-14-custombuttonspageeditor
Try Html.Glass().BeginEditFrame() functionality built into Glass Mapper, wrapped in a #using block.
It allows you to specify the fields you wish to edit directly as params. Or if you're feeling adventurous, it can point to a full edit frame configuration in the core DB.

C++ Windows Forms - Password Strength

I've been following YouTube tutorials most of the day now and I think I've got the basic hang of forms. I'm aiming to create something like this below, which checks a users password and shows how strong it is:
This is what I have at the moment:
I'd like to know the basic theory behind how the top form works, specifically how I can take the user input of password in my form and just get it to print and update in realtime underneath below. I'm not quite sure what tool is used to do that, or for that matter what tool is used to create the colour changing box.
Any help or direction is appreciated, thanks!
Add a keyboardListener to your jtextfield. When a key is pressed get the text and do your stuff(figure out the strength, number of Uppercase etc)
Is this win32 or mfc forms, or some other tech like Qt or wxWidgets?
In both cases you will want to handle messages from the edit field as text is changed in it. This message is the EN_CHANGE message. Handle that message and you can get the text from the edit field and send messages to the strength form to tell it to change its color and text.
Add a System::Windows::Forms::KeyPressEventHandler (or similar) to the TextBox. When raised, do whatever analysis you need to do on the string and update the table below. The color changing box can be one of many implementations. It can be something as simple as a panel that changes its background with a System::Windows::Forms::Label positioned on top of it. It actually looks like that, as the text is not centered.

Iterating through checkboxes in Qt

i thought about making an Url shortener app. That's how the GUI looks like:
Now i have 2 "big" problems because i've never done such things so far.
The first one:
In order to see which checkbox(es) has(have) been checked i need to iterate through them all. How do i do that? because i just dragged&dropped them into my app. I know i should put them into a QListWidget or something like that but i don't know which one.
The second:
How do i submit the link from my app to these url shortener sites and get them back? I'm fairly new to such things. Could you point me to some good tutorials on how to do that? is there an app written in qt so i could look into it's code?
You should use QObject::findChildren()
QList<QCheckBox *> l_checkboxes = parentWidget.findChildren<QCheckBox *>();
where parentWidget is your dialog.
Also, as it performs the search recursively, i would put all checkboxes into a QFrame, QGroupBox, or similar, to reduce the search to such parent widget.
For the second part. It varies for each url shortener. I never worked with em, but, you prolly will have to either:
use the api
Make http post requests as if you were sending
the form from their respective pages.
You can start looking Qt HTTP requests on Google

how to add a simple message to a php-gtk statusbar?

I have a simple GtkStatusBar created with glade,and want to add a simple message with the date of the last update of the database (just a simple and plain date).
I don't want to use the whole stacks, context and all the other things that gtk developers put on the statusbar code.
(I could simply use a label but I would like to keep the drag bar).
I'm using Gtk 2.0.1 with php 5.2.6;
try
http://www.kksou.com/php-gtk2/articles/have-a-status-area-using-GtkStatusbar.php
To display a message, we need to first get a message id with GtkStatusbar::get_context_id(), then display the message with GtkStatusbar::push().