Results 1 to 3 of 3

Thread: custom widgets: passing new parameters to constructor (not only QWidget *parent)

  1. #1
    Join Date
    Apr 2010
    Posts
    4
    Thanks
    1

    Default custom widgets: passing new parameters to constructor (not only QWidget *parent)

    Hello everyone,

    I am trying to integrate a custom widget that I created. But I am having problems because my widget receives in its constructor no only the QWidget *parent but other parameters. I want it to integrate it into QT designer, either as a plugin or as a custom widget but I cannot find the way to tell QT Designer that it has more parameters in the constructor...

    i.e. my custom widget constructor looks like this

    EMI12Interface(AMManager *manager,QWidget *parent);

    EMI12Interface is a QWidget but it receives no only a QWidget *parent in its construction but some other parameters...

    At the time that I add my custom widget to QT Designer and QT Designer autogenerates my source file, my QWidget is created as :

    eMI12Interface1 = new EMI12Interface( ECGWidget, "eMI12Interface1" );

    and this are not the arguments that I want... How can I tell QT Designers to create my QWidget with other arguments?

    Thanks for the help!
    Mario

  2. #2
    Join Date
    Apr 2010
    Location
    Rostov-na-Donu, Russia
    Posts
    153
    Thanks
    2
    Thanked 26 Times in 23 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: custom widgets: passing new parameters to constructor (not only QWidget *parent)

    > How can I tell QT Designers to create my QWidget with other arguments?
    I think, that you can't, because QDesigner doesn't know about value of argument, that it should set while calling your constructor.
    You can:
    1. Make a default value for your parameters, as this
    Qt Code:
    1. MyClass( QWidget * parent, MyParamClass myParam = (), QString initString = "initialize" )
    To copy to clipboard, switch view to plain text mode 
    2. Make two constructors: with standard Qt's parameter QWidget * parent, and with your own parameters, and call the second if you're creating you class from code
    3. Add function(s) to your class, that will set parameters (as Qt likes to do, for example: QFile( QString filename ) and QFile::setFileName( QString filename )

  3. The following user says thank you to borisbn for this useful post:

    mario-huizar (22nd April 2010)

  4. #3
    Join Date
    Apr 2010
    Posts
    4
    Thanks
    1

    Default Re: custom widgets: passing new parameters to constructor (not only QWidget *parent)

    Yeah I think what I will do is to make one init() methode and this init() method will receive all the arguments that my class needs.

Similar Threads

  1. Replies: 1
    Last Post: 22nd April 2010, 14:34
  2. passing parameters to Active-x in hash does not work
    By yazwas in forum Qt Programming
    Replies: 0
    Last Post: 26th February 2010, 11:53
  3. Replies: 7
    Last Post: 23rd January 2010, 22:59
  4. default parameters in constructor class
    By mickey in forum General Programming
    Replies: 4
    Last Post: 23rd February 2008, 18:44
  5. Replies: 2
    Last Post: 17th October 2006, 19:25

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.