ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
So the object is in an other class.
KDE app, QT-designer based, so TextEdit_1 is in the designer based
class and the open_file function in the kde MainWindow class.
O.K. C++ signals seems to be not allowed in Qt-designer (moc).
So I studied all about events and what is the best for my problem and did read the book "C++ GUI Programming with Qt 3".
Now I programmed with:
QCustomEvent ( int type ) - I use "1001" for my event(open File)
customEvent
All compiled pretty so far, but when I "make" that event(open File) in my app it crashes with exit code 253.
What happened? Is that a protection fault?
What details have I to write here, that you can help me?
Run your program under gdb (compile in debig mode with -g option). Cause it to crash, gdb should tell you which function it was, then you can use 'bt' gdb command to see the sequence of function calls that led to the problem.
O.K, I get this:
Program received signal SIGSEGV, Segmentation fault.
Yes, the signal is right, but segmentation fault?
I think it's the same case like with c++ signals. Functions in Qt-classes
can only be called over signals of a Q_OBJECT - in short, only something visible can call a Qt-member-function?
And my only disadvantage is that it isn't allowed to do source coding in kdesigner.
So I think I have to write and add a custom widget including QTextEdit that I can put in my layout with kdesigner. And that custom widget has to have a signal that can not be emit by the user or the system.
So if I emit that signal in the c++ body it should work?
Now I'll study a little more about custom widgets in QT-Designer.
Now I'm at point 3 again.
Maybe you have a better idea.
I have only to call myTextEdit->setText(..) of mydesigner.ui class of mycentralwidget.h class from my.cpp::fileOpen(..) slot of KMainWindow class.
I use a project generated by Kdevelope 3.1.2 named test -
New Project / c++ / KDE / Application framework.
In testview.cpp and .h I made changes to a designer based application
like this:
testView::testView(QWidget* parent, const char* name, WFlags fl )
: M3Dansicht(parent,name,fl )
M3Dansicht is in 3Dansicht.ui and is now my central widget.
I think KMainWindow has an eventloop and M3Dansicht too.
The menu and the toolbar are KMainWindow events, and that what I want to do [ ncbefehlseditor->setText(str1.read()); ] is in the M3Dansicht event loop.
And whatever I do to connect to these events (functions) I get an error or crash.
O.K., I get it.
I didn't recognize that in test.cpp the central widget was set - so I have
access over "this->centralWidget()" to my slots of my .ui file.
Nevertheless many thanks to you, Mara.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.