Results 1 to 6 of 6

Thread: Qlistwidget plugin problem

  1. #1
    Join Date
    Jun 2007
    Posts
    10
    Qt products
    Qt4

    Default Qlistwidget plugin problem

    Hello,
    I am trying to make a qlistwidgetplugin.
    I also write the my own listwidgetitem.
    I want my listwidgetitems with an icon in default.
    So I am setting an icon in the constructor of the listwidgetitem.

    But when I add my plugin listwidget to the designer , at first time everything is
    ok .. I can see the icon on the items. But when I compile and run the application
    the items on the widget are seen without icon.

    Have you got any idea?

    Thanks in advance..

  2. #2
    Join Date
    May 2007
    Location
    Netherlands
    Posts
    11
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanked 3 Times in 3 Posts

    Default Re: Qlistwidget plugin problem

    Can you drop the source code?

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: Qlistwidget plugin problem

    Perhaps the icon file cannot be found? Try embedding it as resource.
    J-P Nurmi

  4. #4
    Join Date
    Jun 2007
    Posts
    10
    Qt products
    Qt4

    Default Re: Qlistwidget plugin problem

    My Code is here,
    Now when I compile this plugin code, At first when I adding an item to the listwidget,
    it is ok but when I run the application,
    in the first row I see the icon, and on the other rows I see only the text that I entered
    from the menu..

    this is list.cpp--------------------

    List::List( QWidget *parent ) : QListWidget(parent)
    {

    row = 0;

    mMenu = new QMenu(this);
    mMenuActionGroup = new QActionGroup( this );

    mMenu->setFont(I90Font(FT_LUCIDA));


    connect( this, SIGNAL(currentTextChanged(QString)), SLOT(currentTextChangeOccur(QString)) );
    // connect (mMenu, SIGNAL(triggered(QAction *)),SLOT(menuItemSelected(QAction *)));
    }

    List::~List()
    {

    }

    void List::currentTextChangeOccur(const QString &text)
    {

    itemText = text;
    emit currentTextChanged(itemText);
    }


    void List :: setMenuItems( const QString &pItems )
    {

    //this->clear();

    itemText = pItems;
    QStringList list = itemText.split( QString("&&") );
    QStringListIterator i(list);

    while (i.hasNext())
    {

    printf("Setting text items\n");
    QListWidgetItem *newItem = new QListWidgetItem();
    newItem->setText(i.next());
    QPixmap px( 32, 32 );
    px.fill(I90Color(CT_GRAY));
    QIcon mItemIcon;
    mItemIcon.addPixmap(px,QIcon::Mode::Selected,QIcon ::State::Off);
    newItem->setIcon(mItemIcon);
    insertItem(row, newItem);
    row++;
    }

    }

    QString List::getMenuItems() const
    {
    return mMenuItems;
    }

    void List ::setCaption (QListWidgetItem pItem)
    {
    setCurrentItem( &pItem );
    }

    QListWidgetItem* List ::caption() const
    {
    return currentItem();
    }
    ----------------------------------------------------------------------
    this is listmenudialog.cpp

    #include "listmenudialog.h"
    #include <QDesignerFormWindowInterface>
    #include <QDesignerFormWindowCursorInterface>

    ListMenuDialog::ListMenuDialog(List * pBtn, QWidget *pParent)
    : QDialog(pParent)
    {
    mBtn = pBtn;
    ui.setupUi(this);
    connect(ui.okButton, SIGNAL(clicked()), this, SLOT(saveList()));
    //ui.menulistTextEdit->setPlainText( mBtn->getMenuItems().join(tr("\n")) );
    QStringList list = pBtn->getMenuItems().split( tr("&&") );
    ui.menulistTextEdit->setPlainText( list.join(tr("\n")) );
    }

    ListMenuDialog::~ListMenuDialog()
    {

    }

    void ListMenuDialog::saveList()
    {
    if (QDesignerFormWindowInterface *formWindow
    = QDesignerFormWindowInterface::findFormWindow(mBtn) )
    {
    QStringList list = ui.menulistTextEdit->toPlainText().split( QChar('\n') );
    formWindow->cursor()->setProperty( "MENU_ITEMS", list.join(QObject::tr("&&")) );
    }
    accept();
    }

  5. #5
    Join Date
    Jun 2007
    Posts
    10
    Qt products
    Qt4

    Default Re: Qlistwidget plugin problem

    Hi,

    I am getting crazy about qlistwidget plugin.

    I am adding only two items but it adds three items.

    At first time on the designer everything is ok but when I save form and run the application

    there are three columns on the list widget.
    what can be the problem..

  6. #6
    Join Date
    Jun 2007
    Posts
    10
    Qt products
    Qt4

    Default Re: Qlistwidget plugin problem

    yes I am embedding as resource

Similar Threads

  1. plugin loading problem
    By naresh in forum Qt Programming
    Replies: 6
    Last Post: 9th June 2007, 19:05
  2. QPSQL plugin problem
    By tuxi in forum Qt Programming
    Replies: 0
    Last Post: 12th March 2007, 20:44
  3. plugin problem
    By whoops.slo in forum Newbie
    Replies: 1
    Last Post: 8th February 2007, 10:03
  4. Replies: 13
    Last Post: 15th December 2006, 11:52
  5. Replies: 7
    Last Post: 3rd February 2006, 10:20

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
  •  
Qt is a trademark of The Qt Company.