Bug in Qt5.2.1:
The only problem was corrected in QPrintPreviewDialog but when the print is printed on paper the failure still exists.
With QPrintPreviewDialog pages work perfect, but on "paper" (printed in paper) from second page (in other words all pages except the first occur the BUG) "texts" and "images" (non-background) disappear (apparently the fault only occurs with inline elements).
See:
https://bugreports.qt.io/browse/QTBUG-37240 (see the attachments to a test-case)
Bug in Qt5.0.1, Qt5.0.2 and Qt5.1.0
The first page of the print out of a QWebView with small fonts and images.
Apparently the problem only occurs with inline elements (texts and images).
Note: The error occurs in Windows XP, Windows 7, Window 7 x64, Mac OS X 10.8.3
[edit]
Source-html: http://jsfiddle.net/bdm6Y/2/
Frame content: http://jsfiddle.net/bdm6Y/2/show/
Source:
QPrinter p;
p.setPaperSize(QPrinter::A4);
p.setFullPage(true);
p.setResolution(300);
p.setOrientation(QPrinter::Portrait);
QPrintPreviewDialog preview(&p);
preview.setWindowTitle(ui->myWebView->page()->mainFrame()->title());
connect(&preview, SIGNAL(paintRequested(QPrinter*)), this, SLOT(printPreview(QPrinter*)));
preview.exec();
...
void printPreview(QPrinter *printer) {
ui->myWebView->print(printer);
}
I do not know if this is a bug or something I did wrong, what could it be?
Thanks!
[edit]
QT bug reports:
https://bugreports.qt.io/browse/QTBUG-30621
Problem fixed in Qt5.3
Qt 5.3 Print Support
New QPA class QPlatformPrintDevice to abstract platform print device hardware, new implementations for Windows, Mac and Linux.
QPrinterInfo provides more details on the print device hardware
QPrinter uses QPageSize and QPageLayout to improve page layout handling
QPrinter has had the behaviour of most functions standardised across all platforms (as detailed below)
Mac can now have each painted page with a different orientation, and can set Collate Copies and Document Name.
Mac and Windows now support setting Document Creator and Duplex Mode
Mac and Linux now support using Windows Page ID (DMPAPER values)
Linux now requires CUPS 1.4 (RHEL 5 no longer supported)
Code tested in Windows:
QPrinter print(QPrinter::HighResolution);
print.setPageMargins(qreal(1), qreal(1), qreal(1), qreal(1), QPrinter::Millimeter);
print.setPaperSize(QPagedPaintDevice::A4);
QPrintPreviewDialog pd(&print, mwindow, Qt::Window);
QObject::connect(&pd, SIGNAL(paintRequested(QPrinter *)), this, SLOT(preview(QPrinter *)));
if(pd.exec() == QPrintPreviewDialog::Accepted) {
/*something*/
}
...
void MainWindow::preview(QPrinter* p) {
mframe->print(p);//mframe is an QWebFrame
}
Related
Below a screenshot of my application. I want to get rid of the white spaces after the last tables lines marked by red rectangles :
The horizontal size policy is expanding and the vertical one is minimum and for other tables it is both set to expanding.
I'm using this method I found in another SO question but as you can see the result is not flawless.
void verticalResizeTableViewToContents(QTableView* tableView)
{
tableView->resizeRowsToContents();
// does it work ?
tableView->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
int rowTotalHeight = 0;
// Rows height
int count = tableView->verticalHeader()->count();
for (int i = 0; i < count; ++i) {
// 2018-03 edit: only account for row if it is visible
if (!tableView->verticalHeader()->isSectionHidden(i)) {
rowTotalHeight += tableView->verticalHeader()->sectionSize(i);
}
}
// Check for scrollbar visibility
if (!tableView->horizontalScrollBar()->isHidden())
{
rowTotalHeight += tableView->horizontalScrollBar()->height();
}
// Check for header visibility
if (!tableView->horizontalHeader()->isHidden())
{
rowTotalHeight += tableView->horizontalHeader()->height();
}
tableView->setMaximumHeight(rowTotalHeight);
}
Somewhere, I'm using this code to setup one of the tables :
m_Internals->Ui.Measures->setModel(mm->getPh66MeasuresModel());
m_Internals->Ui.Measures->horizontalHeader()->setSectionsMovable(true);
m_Internals->Ui.Measures->horizontalHeader()->setHighlightSections(false);
m_Internals->Ui.Measures->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
m_Internals->Ui.Measures->horizontalHeader()->setStretchLastSection(true);
m_Internals->Ui.Measures->verticalHeader()->hide();
m_Internals->Ui.Measures->setSelectionBehavior(QAbstractItemView::SelectRows);
verticalResizeTableViewToContents(m_Internals->Ui.Measures);
I'm using Qt ModelView pattern to populate/update the tables.
Update : I made a small example to reproduce this issue with QTableView : https://github.com/embeddedmz/QTableViewAdjustPolicyNotWorkingProperly
Using the latest Qt version (from Qt official installer), there's no issue. However, using the Qt library provided by vcpkg (outdated for sure) the issue is there.
With Qt provided by vcpkg :
With the latest Qt provided by the Qt Company (update not the latest, it's 5.12.11) :
If you have something fully buildable on Ubuntu 20.04 LTS, post a link to the complete project (strip it down to just this part) and I will take an actual stab at it.
My gut, having worked with Qt for years, is telling me you are being burned by Margins.
https://doc.qt.io/qt-5/qwidget.html#contentsMargins
You probably need to set a bottom margin of Zero.
https://doc.qt.io/qt-5/qmargins.html#setBottom
If you retrieve the margins for those widgets you will probably find they are non-zero.
you can also fix your problem with one trick, this problem happens for you because your data is lower than the table size. I clone your project and change sizepolicy
Under Qt 5.12.11, the bug does not exist. So I took a look at the QAbstractScrollArea::sizeHint code of this version and compared it with the implementation used in recent versions of Qt and found that setting verticalScrollBarPolicy to "ScrollBarAlwaysOff" the "AdjustToContents" adjustment policy works. The default value was "ScrollBarAsNeeded", in fact we can see that this value is not handled but since in Qt 5.12.11 we only compare the vertical|horizontal]scrollBarPolicy to Qt::ScrollBarAlwaysOn it prevents this bug from appearing.
I can succesfully save video which I captured from c++ opencv there is no problem.
Bu similar code not capturing the video. Just opening out.avi . and only 6 kb.
I put the code in showframe func. there is no resizing fyi.
Anybody has experience with the opencv videowriter on the Qt?
void Widget::show_frame(Mat &image)
{
Mat resized_image = image.clone();
video.write(image);
int width_of_label = ui->label_camera->width();
int height_of_label = ui->label_camera->height();
Size size(width_of_label, height_of_label);
// cv::resize(image, resized_image, size);
cvtColor(image,image,CV_BGR2RGB);
cvtColor(resized_image, resized_image, CV_BGR2RGB);
ps : Platform MacOSX
I encountered the same problem with you, and I have tried many solutions, I think you can make the fifth parameter of videowriter() be false. That is, VideoWriter out = VideoWriter(video_name, CV_FOURCC('D', 'I', 'V', 'X'),frame_fps,Size(frame_width,frame_height),false). This works for me!
make sure that your application has access to the opencv_ffmpeg*.dll. For example place it in the working directory or the PATH variable.
Try different codecs, too. Afaik, MJPG did work on all tested machines/systems so far.
I've already solved this by not displaying the last letter of the word then locating the last letter and making it blink then I displayed the word inversely minus the last letter of course.
#include<string.h>
#include<conio.h>
#include<iostream.h>
#include<stdio.h>
char text[255];
int txtposition,txtlength;
void main()
{
clrscr();
gets(text);
txtlength=strlen(text);
char lastchar=text[txtlength-1];
cout<<"Your text is: ";
for(txtposition=0;txtposition<txtlength-1;txtposition++)
{
cout<<text[txtposition];
}
textcolor(WHITE+128);
cprintf("%c", lastchar);
for(txtposition=txtlength-2;txtposition>=0;txtposition--)
{
cout<<text[txtposition];
}
getch();
}
Thank you for all your help!
To make the middle character blink, either your output terminal needs to be capable to present blinking characters using a special terminal control code as described here, or use the gotoxy() function from a separate thread, that displays a ' ' or the actual character, alternating for a specific blink frequency.
The standard C++ library does not provide any facility for making characters blink.
You can do that in platform-specific ways, but it's worth noting that Windows console windows do not (as far as I know) directly support text blinking, like the original IBM PC's text screen mode did. On the original IBM PC one bit of the color specification could be configured to either yield high intensity or blinking, with blinking control as the default. I always reconfigured it to high intensity in my programs, and in the corresponding mechanism for Windows console windows the bits always determine color.
So, it would be complicated to do even in Windows, unless you're running in a DOSBox, which emulates the old PC. I don't know what functionality it offers. Maybe it even does blinking.
But you can easily mark the relevant letters in other ways.
For example, you could use
uppercase versus lowercase,
underlining characters placed on the next line,
parentheses (as you did in your example here),
colors (platform specific),
a different font, boldness, whatever.
I recommend updating to a modern compiler, if you have an ordinary modern PC. Compilers are free. Also you need better learning material, e.g. void main is non-standard and is only accepted by a few compilers.
Looks like for Turbo C/C++ you can you use the Graphics library and/or builtin conio functions. ( https://answers.yahoo.com/question/index?qid=20080813072809AAEguz0 )
But the above is not portable as the graphics library is specific to Turbo and conio is specific to some dos based compilers/libraries.
If you move to the a complier like gcc/g++ then you might want to look at curses library: http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/
Javascript in a web application runs the following loop:
for (var name in this) {
if(typeof(this[name]) == "function") {
if((/^on_|^do_/).test(name)) {
console.debug("Adding ", name, " to ", this, "(", this[name], ")");
f = this[name].bind;
console.debug(f);
this[name] = this[name].bind(this);
}
}
}
Under Chrome 24.0.1312.56, the line f = this[name].bind correctly sets f to the native code function.bind(), while in my QWebKit Qt application it sets f to 'undefined'.
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/bind
Any idea how I'd be able to convince QtWebkit to behave correctly here?
Apparently, Function.prototype.bind is part of ECMAScript 5. It's implementation in webkit should be covered by (fixed bug): https://bugs.webkit.org/show_bug.cgi?id=26382
Perhaps there is a mode to enable ECMAScript 5 that i'm missing?
Apparently i'm using version 534.34 for QtWebkit:
(Pdb) str(QtWebKit.qWebKitVersion())
'534.34'
Which according to this:
https://trac.webkit.org/changeset/85696/trunk/Source/WebKit/mac/Configurations/Version.xcconfig
Corresponds to revision 85696. Combined with the comment in the above bug ("Fixed in r95751"), seems like I need a newer version, specifically anything better than 535.5. Now to find what version of PyQt uses that...
Thanks.
It seems that the latest version of PyQt (4.9.6-1) is compiled against wekbit version 534.34.
The first release of webkit that supports Function.prototype.bind is 535.5.
In addition, it seems that both PySite 1.2.2 and PyQt 4.9.6-1 report webkit version 535.34, and do not have Function.prototype.bind.
Try using the following code which forces you to use Function.prototype.bind
this[name] = Function.prototype.bind.call(this[name], this)
In IE, some of the host objects don't have a bind method on their methods (functions)... could be something related.
I've been browsing the Qt source code trying to find the actual system calls but it seems Qt doesn't use the Windows API documented on MSDN. For example grepping the source for "GetClipboardData" returns results in two files:
qclipboard_win.cpp:
#if defined(Q_OS_WINCE)
...
HANDLE clipData = GetClipboardData(CF_TEXT)
qaxserverbase.cpp:
STDMETHOD(GetClipboardData)(DWORD dwReserved, IDataObject** ppDataObject);
...
HRESULT WINAPI QAxServerBase::GetClipboardData(DWORD, IDataObject**)
{
return E_NOTIMPL;
}
and "SetClipboardData":
qclipboard_win.cpp:
#if defined(Q_OS_WINCE)
...
result = SetClipboardData(CF_UNICODETEXT, wcsdup(reinterpret_cast<const wchar_t *> (data->text().utf16()))) != NULL;
Neither of which seems useful, since they're being declared for Win CE/Mobile.
My Qt (4.8.1) uses OleSetClipboard and OleGetClipboard. The lines you got to are never reached in regular windows, as only in case of #if defined(Q_OS_WINCE) Qt uses #define OleSetClipboard QtCeSetClipboard and #define OleGetClipboard QtCeGetClipboard, and otherwise uses system-provided versions of those functions.
It was a little dificult to see this #if defined though, so you are excused ;)
It is so at least on my Qt version. If you are talking about qt, and especially about it's internals, you should menstion the version, right?