Results 1 to 20 of 32

Thread: Qcombobox

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Re: Qcombobox

    I edited my previous post because I sent it by my mistake

  2. #2
    Join Date
    Apr 2013
    Location
    Prague
    Posts
    258
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    3
    Thanked 65 Times in 59 Posts

    Default Re: Qcombobox

    I do not know what is wrong, either. IMO, the code should work. Try:
    (1) Remove QObject and QWidget includes - they are included by QComboBox
    (2) Add "virtual" specifiers to the dtor and the mouse handler. Well, you need not according to the C++ specification - because both methods are already virtual.
    (3) Remove the "void" parameter from clicked(). Well, the "old" syntax is still legal but contemporary C++ is rather "clicked()" than "clicked(void)"
    (3) If it does not help, delete the compiled files directory and make Creator to build everything from (real) scratch.

  3. #3

    Default Re: Qcombobox

    Qt Code:
    1. #include "mycombobox.h"
    2.  
    3. MyCombobox::MyCombobox(QWidget *parent) : QComboBox(parent)
    4. {
    5.  
    6. }
    7.  
    8. MyCombobox::~MyCombobox()
    9. {
    10.  
    11. }
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. #ifndef MYCOMBOBOX_H
    2. #define MYCOMBOBOX_H
    3.  
    4. #include <QObject>
    5. #include <QWidget>
    6. #include <QComboBox>
    7.  
    8. class MyCombobox : public QComboBox
    9. {
    10. Q_OBJECT
    11. public:
    12. MyCombobox(QWidget *parent = 0);
    13. ~MyCombobox();
    14. };
    15.  
    16. #endif // MYCOMBOBOX_H
    To copy to clipboard, switch view to plain text mode 

    The error is when I only use the above code without QMouseEvent etc

  4. #4
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanked 342 Times in 324 Posts

    Default Re: Qcombobox

    Code looks ok. Be sure to include 'mycombobox.h' in the HEADERS list in .pro file and re-run qmake.
    Can you verify that "moc_mycombobox.cpp" file is created somewhere under the build directory ?

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: Qcombobox

    Rerun qmake after adding/removing the Q_OBJECT macro, then rebuild.

    Err... Ignore me, I missed a whole set of replies.
    Last edited by ChrisW67; 31st May 2015 at 21:28. Reason: updated contents

Similar Threads

  1. Replies: 1
    Last Post: 20th May 2015, 11:21
  2. QComboBox
    By ToddAtWSU in forum Qt Programming
    Replies: 2
    Last Post: 20th January 2014, 14:14
  3. QComboBox
    By kavinsiva in forum Qt Programming
    Replies: 3
    Last Post: 10th August 2009, 16:11
  4. QComboBox
    By bismitapadhy in forum Qt Programming
    Replies: 7
    Last Post: 15th July 2009, 06:01
  5. QComboBox
    By coderbob in forum Qt Programming
    Replies: 4
    Last Post: 12th December 2007, 06:38

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.