Qt - focus on a specified area of webpage - qt

I'm trying to create a plugin using QT that is able to open a webpage, yet I only want the window to be focused on a 300x300 pixel area. The area is somewhere in the middle of a page.
I was able to load the page and then perform a scrolling operation, but that doesn't seem very clean.
Does anyone know if this is possible? I checked the QtWebFrame class reference:
http://doc.qt.io/archives/qt-4.7/qwebframe.html
but maybe I'm missing something. Thanks in advance!

If you don't need interaction with the page, you could call QWebFrame::render(QPainter* painter, const QRegion& clip) and draw it onto a widget, specifying clip to be the required area.

Related

Qt Scrollbar in QLabel

I have a small problem whit QScrollbar.
for example,
This is a one my project in C#
At left panel, the user loads a graphic image and can pick elements.
but I see in Qt don't exist Split Panel whit automatic Scrollbar.
I tried to use QScrollArea, but if user maximizes Window it's a problem.
anyone have a solution or a good way to make this in qt?

Qt Screenshot sharing app - How to select the area of a screen

I am trying to code an app in Qt for capturing and then sharing the screenshots. For now my application captures the screenshot, shows a preview and saves it. I am yet to do the upload part. but before that I would like to be able to select the area of the screen of which the screenshot needs to be captured.
I tried searching and I couldn't find any helpful articles or documents in Qt. So can anyone help me?
PS: The idea is to create a similar app like lightshot and several other similar tools.
Thanks in advance
There are two methods that you can use for this: -
1) Capture an image of the screen and then display that, full screen to the user, essentially allowing the user to crop the image.
2) A more commonly used method is to create a full-screen, topmost window that has no title bar and is transparent. This allows the user to drag out an area, which you can draw an outline to represent the area the user requires.
I recommend the 2nd method and creating a transparent window is simply a matter of changing the window flags, as you can see here.

Qml Flickable Pages

If I wanted to create a flickable looping page menu basically like the Symbian home screen, what element would I use a possibly how would I use it?
I have tried creating "page" elements in QML and then creating a flickable element with 3 pages on, when you flick the pages are changed according to a list and then the fickable is centered allowing you to loop through the pages but it isn't nearly as smooth as the native Symbian home screen. It doesn't finish the flick to the next page automatically; it also doesn't detect slow flicks which results in the pages not being changed and centered meaning you have to flick in the other direction and then back. It is also a bit confusing having to make the page on the flickable equal to another one on the list so I would like to be able to place all the pages on the element instead of having to swap pages. I haven't actually figured out how to swap pages yet as I am just still experimenting with colored rectangles and have noticed the above problems.
I think I should rather use something like Listview but I can't figure out how. If you have any idea's or experience with this, please help!
Yes, you should be using a ListView. With snapMode set to ListView.SnapOneItem.

I do I get QDialog geometry to expand in fullscreen?

I'm trying to get a fullscreen dialog to launch after clicking a button in my MainWindow using QT on Mac. I use showFullScreen() to display the dialog, and the whole screen does get taken up. The problem is that the widgets within the dialog are still constrained to the 1024px geometry set for the dialog in the designer, and positioned in the upper left corner of the screen. I can manually change the geometry in the ui file to match my desktop, but I can't get it to work programmatically. I have tried setting the geometry of the dialog to desktop()->geometry() and the running updateGeometry() and that did not work. I tried it both before and after running the showFullScreen() function.
I've tried setting the sizePolicy of the dialog to Expandable, Maximum, Preferred, and just about every other setting, and still no go. Right now it is an absolute bare bones project, show the only code to show would be the sessionscreen.showFullScreen() function in the button_clicked() slot.
I'm sure there is something I'm missing, but I have been at it for hours, scouring Google and Qt help forums and coming up empty. Hopefully someone can point out something very simple that I am missing.
Nevermind, I am indeed using layouts wrong, because the widgets don't move if i resize the layout in designer either. I thought I followed the tutorial videos exactly. This is why I prefer text based tutorials. Oh well, back to Youtube I go.

Qt switching between views

How do I switch between the two screens on the Qt?
For example, I have a button - static text plus a toolbar. Now I will add it to a frame and set it as a central widget. It works well for one window. What if I move it to the next window? Then I need to show some other stuff like another button, some images etc... and what if I come back to the first view again?
How do I show my old widgets back?
I'm not sure I got your problem right but, you could have different scenarios :
You could simply use groupboxes... Some widgets in groupbox1, otherWidget in groupbox2, and you display the groupbox you want to use, hiding the others...
You could use stackedWidget, which simulates "pages" of widgets stacked on top of eachothers... more informations here : http://qt.nokia.com/doc/4.6/qstackedwidget.html.
You could use other way like using tabs : http://doc.trolltech.com/4.6/qtabwidget.html
Maybe this example would be useful to you : http://qt.nokia.com/doc/4.6/dialogs-configdialog.html
Hope it helps a bit !
I'd recommend checking out Animation/States example (should be in /qt/examples/animation/states/ subdirectory of your Qt installation). It shows how to combine state machine representing application logic with presentation layer and get cool animation effects for free (of course if you don't need eye candy, you can set widgets properties without any animation).

Resources