Results 1 to 5 of 5

Thread: Add to KeyListWidget of another class

  1. #1
    Join Date
    May 2009
    Posts
    94
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Post Add to KeyListWidget of another class

    I have one class1 abc - contains a QListWidget testscript
    class2 test1 - Dialog - onOK() - add a string to the testscript QListwidget
    class3 test2 - Dialog - onOK() - append a string to the testscript QListwidget

    Everytime i can't create a object of the class1, because on creating object it will call the constructor and call the dialog.

    Using the class name i am unable to add into QListWidget testscript. How can i do it give me any idea.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Add to KeyListWidget of another class

    Quote Originally Posted by bismitapadhy View Post
    How can i do it give me any idea.
    Sorry, but I don't understand your question. Can you provide a minimal code example illustrating your problem.

  3. #3
    Join Date
    May 2009
    Posts
    94
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Post Re: Add to KeyListWidget of another class

    Quote Originally Posted by Lykurg View Post
    Sorry, but I don't understand your question. Can you provide a minimal code example illustrating your problem.
    TestScriptGeneratorDialog::TestScriptGeneratorDial og(QWidget * parent): QDialog(parent)
    {
    setWindowTitle(tr("Test Script Generator"));
    m_commandList = new QListWidget;
    m_scriptList = new QListWidget;
    }

    void TestScriptGeneratorDialog::updateScriptList(QStrin g script)
    {
    m_scriptList->addItem(script); //List is not adding
    }

    PressKeyDialog::PressKeyDialog(QWidget * parent): QDialog(parent)
    {
    QPushButton *okButton = new QPushButton(tr("Ok"));
    QPushButton *closeButton = new QPushButton(tr("Cancel"));

    connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
    connect(okButton, SIGNAL(clicked()), this, SLOT(onOk()));
    }

    void PressKeyDialog:nOk(void)
    {

    TestScriptGeneratorDialog *pTestScript = new TestScriptGeneratorDialog;
    pTestScript->updateScriptList(capture);
    }

    The updateScriptList function get executed and the item is not added to the QListWidget. Please let me know what to do.

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Add to KeyListWidget of another class

    Ok where do you call PressKeyDialog and TestScriptGeneratorDialog? are they related?

  5. #5
    Join Date
    May 2009
    Posts
    94
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Add to KeyListWidget of another class

    Quote Originally Posted by Lykurg View Post
    Ok where do you call PressKeyDialog and TestScriptGeneratorDialog? are they related?
    void TestScriptGeneratorDialog:nAdd()
    {
    int currentRow = m_commandList->currentRow();
    PressKeyDialog *m_pressKey;
    ReleaseKeyDialog *m_releaseKey;
    CaptureDialog *m_capture;


    switch(currentRow)
    {
    case 0:
    break;
    case 1:
    m_pressKey = new PressKeyDialog(this);
    if (m_pressKey)
    {
    m_pressKey->exec();
    delete m_pressKey;
    }
    break;
    }
    }

    I am calling presskeydialog from testscriptgeneratordialog.

Similar Threads

  1. Abstract base class and inherited class members
    By JovianGhost in forum General Programming
    Replies: 3
    Last Post: 19th March 2010, 13:32
  2. Replies: 3
    Last Post: 27th December 2008, 20:34
  3. Accessing a class Object by pointer in another class
    By pdoria in forum Qt Programming
    Replies: 2
    Last Post: 14th January 2008, 16:59
  4. Replies: 3
    Last Post: 16th May 2007, 12:07
  5. Signal/slot looking in base class, not derived class
    By georgie in forum Qt Programming
    Replies: 2
    Last Post: 12th May 2006, 08:36

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.