qt - Any alternative soloution for QMessagebox for IOS development (QWidget application only)? -
i new qt , have 2 or 3 moths experiance on it. using qt 5.3 , trying develop application ios.
problem is, qwidget application in iphone retina simulator:
qmessage becomes full-screen. in application output panel see: plugin not back upwards propagatesizehints().so looking alternative solution qmessagebox. don't want larn qml yet.
thanks.
if overlay on top of widget can create similar ios popups.
basically create widget, , parent widget want drawn on top of.
here helpful flags , lines of code set in overlay constructor:
setpalette(qt::transparent); // if have buttons on overlay don't want 1 setattribute(qt::wa_transparentformouseevents); qgraphicsdropshadoweffect * dse = new qgraphicsdropshadoweffect(); dse->setblurradius(20); this->setgraphicseffect(dse); then sure command resize of overlay when parent widget resizes:
void parentwidget::resizeevent(qresizeevent *event) { overlay->resize(event->size()); event->accept(); } http://www.qtcentre.org/wiki/index.php?title=widget_overlay
update: awesome example
main.cpp
#include <qapplication> #include "mainwindow.h" int main(int argc, char *argv[]) { qapplication a(argc, argv); mainwindow w; w.show(); w.resize(300,600); homecoming a.exec(); } mainwindow.h
#ifndef mainwindow_h #define mainwindow_h #include <qmainwindow> #include "overlaydialogbox.h" #include <qresizeevent> class mainwindow : public qmainwindow { q_object public: mainwindow(qwidget *parent = 0); ~mainwindow(); public slots: void resizeevent(qresizeevent *event); private: overlaydialogbox * m_overlay; }; #endif // mainwindow_h mainwindow.cpp
#include "mainwindow.h" mainwindow::mainwindow(qwidget *parent) : qmainwindow(parent) { m_overlay = new overlaydialogbox(this); } mainwindow::~mainwindow() { } void mainwindow::resizeevent(qresizeevent *event) { m_overlay->resize(event->size()); event->accept(); } overlaydialogbox.h
#ifndef overlaydialogbox_h #define overlaydialogbox_h #include <qwidget> class overlaydialogbox : public qwidget { q_object public: explicit overlaydialogbox(qwidget *parent = 0); signals: void accepted(); void rejected(); void finished(int); public slots: }; #endif // overlaydialogbox_h overlaydialogbox.cpp
#include "overlaydialogbox.h" #include <qgridlayout> #include <qgraphicseffect> #include <qlabel> #include <qdialogbuttonbox> #include <qmessagebox> #include <qicon> overlaydialogbox::overlaydialogbox(qwidget *parent) : qwidget(parent) { setpalette(qt::transparent); // if have buttons on overlay don't want 1 // setattribute(qt::wa_transparentformouseevents); qgraphicsdropshadoweffect * dse = new qgraphicsdropshadoweffect(); dse->setblurradius(20); this->setgraphicseffect(dse); qgridlayout * grid = new qgridlayout(); this->setlayout(grid); qmessagebox * msg = new qmessagebox(qmessagebox::warning,"testing","this test qmessagebox."); qobject::connect(msg, signal(accepted()), this, signal(accepted())); qobject::connect(msg, signal(finished(int)), this, signal(finished(int))); qobject::connect(msg, signal(rejected()), this, signal(rejected())); qobject::connect(msg, signal(finished(int)), this, slot(close())); msg->setpalette(qt::white); grid->addwidget(msg); } hope helps.
ios qt qt5
No comments:
Post a Comment