QPrintDialog and setting up the printer - qt

I am working on an application that uses the Qt library on Windows.
I want the user to be able to configure the printer where the application should print. So my main menu will contain the following entries:
Printer Setup...: should show a dialog where the user can select and configure the printer
Print...: perform the actual print
In other, non-Qt, applications I used the Windows function PrintDlg with the flag PD_PRINTSETUP. This showed the following dialog, which is exactly what I want:
However, the Qt function QPrintDialog uses the more recent PrintDlgEx function, which looks like this:
This dialog seems to be intended for actual printing. Not for setting and configuring the printer.
It shows a Print button instead of simply OK.
It contains a 'Page Range' group box, which isn't really useful when setting up the printer configuration.
The QPageSetupDialog isn't really useful in my case either. It looks like this:
So this only makes it useful for setting the page size, the orientation and the margins.
Is there a clean way in Qt to get a decent printer configuration dialog?
If I can't find a clean way, I need to revert to the native Windows PrintDlg function, which means patching or duplicating the code in the Qt source qprintdialog_win.cpp.

I'm afraid you'll need to revert to the native Windows PrintDlg function as Qt4 correctly uses the PageSetupDlg function for page setup.
In Windows, although the PrintDlg can use the PD_PRINTSETUP to make the dialog act as Print Setup Dialog box, that functionality is not reccomended for new applications.
Quoting from MS: "new applications should not use PrintDlg for this purpose. The Print Setup dialog box has been superseded by the Page Setup dialog box created by the PageSetupDlg function."

Related

Opening and Closing Browser

I am new to TOSCA (just trying to learn by self-studying - have a trial license).
I was trying to build a simple test case to open and close an application. In it I have used the TBox Window Operation Module to close the Browser but when I run it in scratchbox, I don't get any output. It just opens the browser to the demo app and exits without giving a success or an error message. I want to know why it isn't closing the browser window and giving me a success message.
Here is a screenshot:
Any help on this is appreciated.
Your testcase looks alright to me. I just tried myself and this should work.
After you've run the test you can always open up the scratchbook again, by clicking the 'scratchbook' button in the ribbon on the 'home' tab in the 'go to' group:
You should then see the details of your last run. A very common thing that happens to me is that Tosca cannot uniquely identify the window (e.g. because I have two windows with the same title open). The error would look like this:
So I'd check if opened the demo webshop more than once.
What is also good to know is, that Tosca will use your standard browser in the 'OpenUrl' module if you have not specified it otherwise, and the 'Window Operation Module' is agnostic to that. You can explicitly specify which browser to use in the 'OpenUrl' module by providing a TestConfiguration Parameter like this:
Hope that helps.
just use CloseBrowser module which can be found under Standard Modules.
Standard Modules are the set of modules which are shipped by default along with the installation of any Tosca instance.
You can use "close browser" standard module instead of window operation module to close the browser window.

Build photo editor interface using Qt

I would like to create an application using Qt (PyQt5 specifically) that has a photo editor like interface. More specifically, I would like it to have:
No main window
Free-floating toolbar
Free-floating context window
Startup dialog
Edit-windows
The idea is to have the toolbar and context window persist for as along as the application is running. The user then opens one or multiple documents (e.g. images in the photo editor example) and uses the options in the toolbar to modify the document(s).
My first question is; does this type of application interface have a specific name, something akin to MDI or SDI? I've been searching for "photo editor interface" and variations on that, but haven't been able to find a search string that seems to hit the mark. For instance, I've tried "build a photo editor type interface with Qt" but it doesn't yield anything useful.
The second question I have is, what is the best way to build a Qt application that doesn't spawn a main window? It seems like I could kludge an assortment of dialogs together to make this happen, but I would really like to use a lot of the functionality of QMainWindow (toolbars, menus, top-level management of the application). Is there a way to launch QMainWindow, display the menu and toolbar, but suppress the main window?
I plan to primarily use this application on OSX, but would also like it to perform well on Windows and Linux.
QMenuBar has explicit support for OSX to have the menu bar behave as expected: http://doc.qt.io/qt-5/qmenubar.html#qmenubar-on-os-x
I think it'll also work on Ubuntu's Unity, which tries to have similar style, but there may be some details you need to take care of. Other desktops should work as expected.
As to how to have individual windows: any Qt widget will be a top level window if it has no parent, so that is an easy way to create windows. If you want to have parent windows (for example to control window stacking order automatically), there's a window flag for that. So you don't need to use QDialog (not sure if you were implying that in your question).
You want to read QWidget documentation carefully to get an idea how all this works.

libvlc_media_player_set_hwnd doesn't work with QWidget Handle

I am using Qt4.8 Windows version to develope an application to stream video using libvlc 2.2.1. When I use libvlc_media_player_set_hwnd() to render the video on my QWidget, its rather creating a separate window to display the video.
libvlc_media_player_set_hwnd(m_player, (void*)videoWidget->winId());
I have tried all versions of libvlc and all the examples related to libvlc with Qt. Also followed the steps given in https://wiki.videolan.org/LibVLC_SampleCode_Qt/
But I am not sure if I m missing anything.
It looks like as if libvlc_media_player_set_hwnd() is not able to take the QWidget WinId and creating its own window. However the value of (void*)videoWidget->winId() seems to be a valid one. (I got the value as 0x65).
Please let me know if I am missing anything.
You need to make sure you are configuring your VLC instance correctly first, so that it uses the dummy interface, for example:
/* Load the VLC engine */
std::vector<const char*> options;
options.push_back("--intf=dummy");
return libvlc_new(int(options.size()), options.data());
Also, are you sure you are passing the handle to the correct widget to render on? Also, make sure to set some size on the parent widget, otherwise you may not see anything render at all. Finally, check what media options you are setting to your media player instance, you may be inadvertently telling it to render to generated window.
I've been able to get VLC to work in my own Qt application using the following example as a starting point, even though it is for VLC 1.X:
LibVLC SampleCode Qt - VideoLAN Wiki

Coded UI Testing in IE - How to upload a file?

With our CUIT tests in Visual Studio we have the problem that we cannot record the Browser Button action in IE. We just get:
C:\fakepath\Document1.txt
But this obviously does not lead to the real document in a playback. And it's not possible to just type the path into the Browse text field anymore.
Just FYI: This applies to the Coded UI Testing Framework in Visual Studio 2010 Feature Pack 2. The recorder only works with IE.
Any ideas?
Not being able to access the file upload control is supposed to be a security feature. I guess you need to step out of your environment and into the windows environment to accomplish anything.
If you use a macro recorder that can playback from command line (like http://www.jitbit.com/macro-recorder/versionhistory/) or a similar means, you may be able to record the missing step here (like a simple tab key hit - provided you have focused on the control before the upload control -, a typed text, and another tab key hit) and start the resulting "batch". Or you can even record a mouse click.
However, if this test runs in other browsers (if I understand you correctly), wouldn't it be safe enough to assume that it runs in IE as well, because after all you are using a standard control?
Actually, turns out I can edit the value "C:\fakepath\Document1.txt" manually in the uitest UIMaps file and change it to a real path. And it works in the reply like this.

Force system cursor usage in Flex

Let's say that you're using some black box library (i.e. no source code) that sets your cursor to something when rolling over a certain sprite. You can override that by catching rollOver and rollOut events, blocking propagation and using the CursorManager.
Question: is there a way to tell the CursorManager to use the system cursor?
Obviously, I could feed the CursorManager some "system like" cursor, but this would look weird if the local settings are different from that icon, which is likely to be always.
thank you!
f
You can create your own version of CursorManager - just create file mx/managers/CursorManager.as, copy it's content from default manager (use Ctrl+Shift+T to navigate to it) and change the code.
If you use RSLs then you need to create monkey-patch and load it BEFORE RSLs.
if you embed SDK into code then you can simply compile the app and class will be replaced.

Resources