Results 1 to 2 of 2

Thread: how to include QThread for main form

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2012
    Posts
    44
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Question how to include QThread for main form

    Qt Code:
    1. #ifndef FRMFIND_H
    2. #define FRMFIND_H
    3.  
    4. #include <QMainWindow>
    5. #include<QThread>
    6.  
    7. namespace Ui {
    8. class frmFind;
    9. }
    10.  
    11. class frmFind : public QMainWindow, QThread
    12. {
    13. Q_OBJECT
    14.  
    15. public:
    16. explicit frmFind(QWidget *parent = 0);
    17. // void run();
    18. void QThread::run();
    19. ~frmFind();
    20. public slots:
    21. void getDirNames();
    22. private slots:
    23. void on_btnSearch_clicked();
    24.  
    25. private:
    26. Ui::frmFind *ui;
    27. };
    28.  
    29. #endif // FRMFIND_H
    To copy to clipboard, switch view to plain text mode 

    when i am including QThread in above way for main Form , it giving this error
    ERROR:
    /PATHNAME/moc_frmfind.cpp:55: error: ‘QObject’ is an ambiguous base of ‘frmFind’
    Last edited by wysota; 7th February 2012 at 14:50. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to include QThread for main form

    You can't inherit from two classes that are derived from QObject. Use composition instead. Also note that you can't access GUI objects from within a worker thread.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QThread sends signal to main thread immediatly
    By BIllNo123 in forum Newbie
    Replies: 7
    Last Post: 27th August 2010, 10:32
  2. How to get a reference for a control of the main form?
    By thiforums in forum Qt Programming
    Replies: 6
    Last Post: 20th March 2009, 17:20
  3. Determine if QThread::currentThread is main thread?
    By chaoticbob in forum Qt Programming
    Replies: 2
    Last Post: 17th December 2008, 06:26
  4. visible main form?
    By triperzonak in forum Newbie
    Replies: 1
    Last Post: 12th June 2008, 09:00
  5. Qt Designer - Fixed size main form
    By nleverin in forum Newbie
    Replies: 3
    Last Post: 25th April 2008, 19:54

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.