Results 1 to 7 of 7

Thread: QWidget - Q_OBJECT makes the widget disappear

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2009
    Posts
    9
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    1

    Default QWidget - Q_OBJECT makes the widget disappear

    Ok hey guys, I have a very very weird bug. If I add the Q_OBJECT line to the class it makes it disappear. I have kept the class very small to show the bug. The class works like a charm when Q_OBJECT isn't present, but I need it to emit signals.
    By disappear I mean that it doesn't show the class at all anymore on the UI, on the widget. It still somewhat works, because it creates a new window if I set the parent to NULL, indicating that the class is still somewhat operational.

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


    rgcbutton.cpp
    Qt Code:
    1. #include "rgcbutton.h"
    2. #include <QMouseEvent>
    3.  
    4. rgcbutton::rgcbutton(QWidget *parent) : QWidget(parent)
    5. {
    6. QImage ximg; ximg.load("skins/default/images/exit_inactive.png");
    7. setStyleSheet("background-image: url(skins/default/images/exit_inactive.png);");
    8. setFixedSize(ximg.size());
    9. }
    10. rgcbutton::~rgcbutton() { }
    To copy to clipboard, switch view to plain text mode 



    Implementation (Some random QWidget
    Qt Code:
    1. login::login(QWidget *parent) : QWidget(parent, Qt::FramelessWindowHint), ui(new Ui::login)
    2. {
    3. ui->setupUi(this); move(QApplication::desktop()->geometry().center() - rect().center());
    4.  
    5. rgcbutton *TT = new rgcbutton(this);
    6. TT->move(20, 20);
    7. }
    To copy to clipboard, switch view to plain text mode 



    I'm stuck on this and I don't know what's happening. Your help is very much appreciated. This is the warning I get when I compile without Q_OBJECT. Maybe it helps: rgcbutton.h:0: Warning: No relevant classes found. No output generated.


    Regards,
    Sir Rogers
    Last edited by wysota; 25th January 2010 at 09:35. Reason: Missing [code] tags

Similar Threads

  1. Replies: 1
    Last Post: 30th March 2009, 14:28
  2. Dynamic widget not displayed upon Qwidget
    By ashukla in forum Qt Programming
    Replies: 5
    Last Post: 17th December 2007, 11:11
  3. get custom widget to inherit qwidget
    By CopyrightPhilly in forum Qt Tools
    Replies: 3
    Last Post: 4th October 2007, 08:58
  4. QLabel::setText causes part of widget to disappear
    By Pieter from Belgium in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2007, 09:22
  5. Replies: 9
    Last Post: 8th May 2006, 14:21

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.