Results 1 to 8 of 8

Thread: Reference to ui

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2010
    Posts
    21
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    2

    Default Re: Reference to ui

    I have an error in ui file, reference on not existed file. Now it types me this ui_filewidget.h:34: error: ISO C++ forbids declaration of 'myListWidget' with no type
    Last edited by Phalanx; 19th April 2010 at 21:26.

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    6
    Thanked 348 Times in 333 Posts

    Default Re: Reference to ui

    You do understand that you should never, ever, edit the generated files such as ui_*.h, right?

  3. #3
    Join Date
    Apr 2010
    Posts
    21
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    2

    Default Re: Reference to ui

    Sure, but I try that. I delete it then and generated new, it is not a problem.

    Problem is how to give an ui to my promoted QListWidget. I cannot use Ui::myListWidgetClass *ui in here. I dont know how to write it. It would be great if I get ui from constructor

    class myListWidget : public QListWidget
    {
    Q_OBJECT
    public:
    explicit myListWidget(QWidget *parent = 0, TableWidget *ref_TableWidget = 0);
    Ui::myListWidgetClass *ui;
    Last edited by Phalanx; 20th April 2010 at 06:03.

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

    Default Re: Reference to ui

    Well you can't design a QListWidget alone in designer. So I guess the QListWidget is in a mainwindow and you want to be able to access other elements like buttons from your subclassed QListWidget. If so, just pass a pointer from the main windows to your subclass. But better is to use signals and slots. Your case is exactly why they exists...

  5. #5
    Join Date
    Apr 2010
    Posts
    21
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    2

    Default Re: Reference to ui

    I know what you mean, it would be great if I can use code example. But I haven't got an ui pointer because I have promoted QListWidget to myListWidget

    action_New = new QAction("&New", ui->treeWidget);
    action_Open = new QAction("&Open", ui->treeWidget);

    //add the code at slots
    connect(action_New, SIGNAL(triggered()), this, SLOT(on_action_New_triggered()));
    connect(action_Open, SIGNAL(triggered()), this, SLOT(on_action_Open_triggered()));

    ui->treeWidget->addAction(action_New);
    ui->treeWidget->addAction(action_Open);
    ui->treeWidget->setContextMenuPolicy(Qt::ActionsContextMenu);

  6. #6
    Join Date
    Apr 2010
    Posts
    21
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    2

    Default Re: Reference to ui

    I have code it by this tutorial (option first): forum_Nokia
    I need to use ui in class RCQListWidget, please help

  7. #7
    Join Date
    Apr 2010
    Posts
    21
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    2

    Default Re: Reference to ui

    Solved. Use first manual but register ui->listWidget->installEventFilter(this); in constructor of up widget

Similar Threads

  1. Undefined reference to crt
    By derektaprell in forum Installation and Deployment
    Replies: 0
    Last Post: 20th October 2009, 08:34
  2. Undefined Reference To...
    By ManuMies in forum Qt Programming
    Replies: 6
    Last Post: 10th February 2009, 12:14
  3. Pass by reference
    By vermarajeev in forum General Programming
    Replies: 6
    Last Post: 20th July 2007, 14:53
  4. Undefined reference
    By Salazaar in forum Newbie
    Replies: 12
    Last Post: 23rd May 2007, 10:21
  5. Reference QTableWidgetItem
    By regenbiegen in forum Qt Programming
    Replies: 2
    Last Post: 1st February 2007, 11:34

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.