<div dir="ltr"><img width="0" height="0" class="mailtrack-img" alt="" style="display:flex" src="https://mailtrack.io/trace/mail/5a6075fd0cd5705a6b0889b898908252b48fca3b.png?u=1477559"><div></div><div class="gmail_quote"><div dir="ltr">On Sat, Jun 9, 2018 at 1:43 AM Tobias Deiminger <<a href="mailto:haxtibal@posteo.de">haxtibal@posteo.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Am 08.06.2018 18:57 schrieb Dileep Sankhla:<br>
> Hello Tobias,<br>
> <br>
> I have succeeded in getting the QInputDialog to write a new note:<br>
> <br>
> QMetaObject::invokeMethod(part.m_pageView, "slotToggleAnnotator",<br>
> Q_ARG( bool, true ));  // displayes the annotation toolbar<br>
> QList<QToolButton *> toolbuttonList =<br>
> part.m_pageView->findChildren<QToolButton *>(); // Get the list of all<br>
> 10 annotation toolbuttons<br>
> <br>
> QToolButton* typewriterButton = toolbuttonList.at(9); // Get's<br>
> typewriter toolbutton at 10th posiiton<br>
> <br>
> typewriterButton->click();  // clicks and selects the typewriter tool<br>
> <br>
> // Clicks on the viewport and a QInputDialog popups<br>
> QTest::mouseMove(part.m_pageView->viewport(), QPoint(width * 0.5,<br>
> height * 0.2));<br>
> QTest::mouseClick(part.m_pageView->viewport(), Qt::LeftButton,<br>
> Qt::NoModifier, QPoint(width * 0.5, height * 0.2));<br>
> <br>
> It popups a multiline QInputDialog annotation window and prompts for<br>
> the note. I write any content, press OK and the test ends.<br>
> My question is how to check if the popup window appears in the test as<br>
> it doesn't have any parent widget? So I can't do findChildren on<br>
> part.m_pageView to check for the QInputDialog.<br>
<br>
QApplication::activeModalWidget [0], QApplication::topLevelWidgets [1] <br>
and friends come to my mind to find the QInputDialog window. You can get <br>
the current QApplication with the qApp macro at any scope.<br></blockquote><div>Actually as soon as the QInputDialog window shows up, it blocks the main UI. Only after manually closing it, the next code to grab the pointer of QInputDialog executes which then gives me the null QWidget. In this case, is there any way to continue with the UI thread and grab the pointer to the dialog without manually interacting with it?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
> And after checking for<br>
> the QInputDialog, how to CANCEL the dialog in the test so that my test<br>
> doesn't pause at user's input prompt? I just need an idea as I'm stuck<br>
> here.<br>
<br>
Once you've got a pointer to the dialog widget, I think you can invoke <br>
QDialog::done [2] to finish text input and continue annotation creation, <br>
or QWidget::close [3] to just close it.<br>
<br>
Had no time to look into the other issues in this thread yet, sorry. <br>
Will answer later unless someone other does.<br>
<br>
Cheers<br>
Tobias<br>
<br>
[0] <a href="http://doc.qt.io/qt-5/qapplication.html#activeModalWidget" rel="noreferrer" target="_blank">http://doc.qt.io/qt-5/qapplication.html#activeModalWidget</a><br>
[1] <a href="http://doc.qt.io/qt-5/qapplication.html#topLevelWidgets" rel="noreferrer" target="_blank">http://doc.qt.io/qt-5/qapplication.html#topLevelWidgets</a><br>
[2] <a href="http://doc.qt.io/qt-5/qdialog.html#done" rel="noreferrer" target="_blank">http://doc.qt.io/qt-5/qdialog.html#done</a><br>
[3] <a href="http://doc.qt.io/qt-5/qwidget.html#close" rel="noreferrer" target="_blank">http://doc.qt.io/qt-5/qwidget.html#close</a><br>
</blockquote></div></div>