Still does not bring up a new dialog
Printable View
Please find the attached example.
thanks, i'll have to study this tonight at work
I dont have main because it is a plasma widget
It's setup like the example you gave me
Code:
: Plasma::Applet(parent, args), m_svg(this), m_icon("document"), m_webapp(NULL), m_setapp(NULL) { m_webapp = new webapp(this); m_setapp = new setapp(); } void mum::settings() { m_setapp->show(); } void mum::web() { m_webapp->show(); }
setapp works as expected
webapp gives the following error
Code:
mum.cpp: In constructor 'mum::mum(QObject*, const QVariantList&)': mum.cpp:30: error: no matching function for call to 'webapp::webapp(mum* const)'
Looks like Plasma::Applet does not inherit QWidget. OK, then you can't have that as parent, just pass NULL as parent and delete webapp in your destructor.
how would i make it show the exisitng m_webapp from m_setapp?
Either create m_webapp inside m_setapp or have m_setapp emit a signal and connect that to the show-slot of m_webapp.
Just delete it in the destructor. (once in the lifetime of your application).
delete it like this?
doesnt seem to delete m_webappCode:
webapp::~webapp(){ delete this; }
also emitting the signal and connecting to it
what am I doing wrong?
or can I do I connect to a slot in a different class?Code:
m_setapp = new SetApp(NULL); connect(m_setapp, SIGNAL(showeb()), this SLOT(web())); } void mum::web() { m_webapp->show(); } .................. connect( pushButton_node, SIGNAL( clicked() ), this, SLOT( node() ) ); } void SetApp::node() { emit showeb(); //this pushbutton code work
delete this in a destructor is an infinite recursion.
delete calls the destructor. It is basically calling a method within itself. This will not work.
Regarding your signal & slots connection: What does not work? Do you get any warnings in the console? Do all connect-statements return true?
Think I've worked it out
I want the plasmoid to display a seperate dialog and QWebView when requested.
I dont want the QWebView to be always loaded but hidden
So currently it does the following, From my understadning
1. when the plasmoid starts it creates the constructor which just creates the dialog
2. when i select the item to show the dialog I use showEvent to create a QWebView and display the page.
3. When I close the dialog I use closeEvent to delete the QWebView
What can I use as profiling software?
Why on earth do you want to create the webView in the showEvent and destroy it when it gets closed? Just do it like anyone else: Create it in the constructor let it Qt destroy when necessary. Dont try to be too clever, keep it simple stupid, trust Qt.
You can use either valgrind or oprofile for profiling. But if there is already need for profiling, then your computer has a problem.
I think it's deleted when you close the dialog. Qt uses to do a lot of hard work for you ;)
Well, if so, you can delete it manually.
Code:
myQtApp *dialog = new myQtApp(this); dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->show(); delete dialog; dialog = 0;
What I do is to create the dialog on the stack. So it will be deleted for sure when it's out of scope. But I do it with small and temporary dialogs.
Code:
myQtApp dialog(this); dialog.setAttribute(Qt::WA_DeleteOnClose); dialog.show();
My application is a plasma widget so 99.99% of the time its just the one widget, there is no reason to have anything else just waiting, hidden, invisible or not shown.
When I use this code
I get this error while compilingCode:
m_setapp = new SetApp(this);
But this works okCode:
mum.cpp: In member function 'void mum::settings()': mum.cpp:75: error: no matching function for call to 'SetApp::SetApp(mum* const)' myqtapp.h:29: note: SetApp::SetApp(const SetApp&)
Code:
m_setapp = new SetApp(NULL);
From what I can tell it's not deleted when it's closed, I have to manually delete it when its closed, then create it again when required
Right, you have to delete it yourself when you close the application.
But again: Dont try to be to clever. Get your application up and running and dont bother too much in saving memory when you are not know what you are actually doing. Keeping the dialog in memory will not hurt very much. I'd keep it there so it gets shown faster the second time I open it.