And just notice that you close the namespace Ui. So your declaration is incorrect. It should beAlso it is a bit strange declaration. Is it designer-made class?Qt Code:
To copy to clipboard, switch view to plain text mode
And just notice that you close the namespace Ui. So your declaration is incorrect. It should beAlso it is a bit strange declaration. Is it designer-made class?Qt Code:
To copy to clipboard, switch view to plain text mode
I mean compile time error. Actually I do prefer to see compile time error instead of looking through the console. So you are half right. Run time error != build time error.Actually, that WOULD produce an error, but at runtime when connect() is called, rather than compile time. You'll get an error stating that there's no such signal.
About dialog. Looks like you draw in designer, right? if so you need multiple inheritance where the first class is exactly the base class of your widget (QDialog, QScrollArea, etc) and second is your Ui based class.
Qt Code:
// Login details dialog { Q_OBJECT public: ~LoginDetails(); } // And in the constructor of this class very urgent to keep the initialization sequence and don't forget to initialize Ui as well LoginDetails::LoginDetails( QWidget* parent, Qt::WindowFlags flags) { setupUi(this); // should go first!!! // Your init }To copy to clipboard, switch view to plain text mode
Hope that helps
I thought I clearly stated that in my post:
It was a "Just for your information". I know it's not a compile time error, but you might not have known about it and thought it was useful. Considering connect() takes a char *, it's impossible for it to know at compile time that a signal doesn't exist. You can put whatever you like for the signal and slot and it'll be happy at compile time.Actually, that WOULD produce an error, but at runtime when connect() is called, rather than compile time. You'll get an error stating that there's no such signal.
You lost me here...Let me see if I understood right, I should use Multiple Inheritance instead of Single Inheritance? The code generated by QtCreator seems to be single inheritance, I never changed that, but is that necessary?
Yes I use the designer to create the forms..
Multiple Inheritance is generally a bad idea. You should use single inheritance unless you have a good reason. This way all your ui objects are behind the 'ui' object rather than exposed and polluting the same class as your implementation. Multiple inheritance also makes it more messy if another class includes your classes header file.
I read at QT archives that QT Creator uses single inheritance because that compiles much quicker and etc, etc ...
But there's this QT beginners tutorial that says multiple inheritance is the preferred way to write Qt applications.
Whatever.... So single inheritance is better?
Use whichever you prefer. I prefer single inheritance as it keep the ui private, but some prefer multiple so they can access the ui directly.
Bookmarks