Wednesday, October 24, 2012

type QWidget is not a direct base of MyWidget


Qt Code:

class MyWidget : public QMainWindow 
{ 
Q_OBJECT 
public: 
explicit MyWidget(QWidget *parent = 0); 

~MyWidget(); 
private: 
Ui::MyWidget *ui; 
}; 

MyWidget::MyWidget(QWidget *parent) 
: QWidget(parent)//ERROR 
{ 
QPushButton *quit = new QPushButton("Close Application", this); 

setGeometry(150,150,100,100); 
setFont(QFont("Times",12,QFont::Bold)); 

connect(quit,SIGNAL(clicked()),qApp,SLOT(quit())); 

Error: Type "QWidget" is not direct base of 'MyWidget'.
you will need to pass the parent to the QMainWindow constructor

MyWidget::MyWidget(QWidget *parent) 

: QMainWindow(parent) // no ERROR 


you will need to pass the parent to the QMainWindow constructor:

If this even does not fix the issue then you may have forgot to include the header file in .h file

# include 
 

Monday, October 22, 2012

Eclipse: convert upper case text to lower case and viceversa with a simple shortcut

This is just a quick post to share these 2 little shortcuts to convert text from lower case to uppercase and viceversa in Eclipse.

Lower case: CTRL+SHIFT+Y (CMD+SHIFT+Y on Mac OS X)

Upper case: CTRL+SHIFT+X (CMD+SHIFT+X on Mac OS X)

In both the combination you can select one or more character to convert.

you can change this setting via Eclipse > Window > Preferences > General > Keys