Active Topics

 


Reply
Thread Tools
Posts: 270 | Thanked: 239 times | Joined on Dec 2009 @ Czech Republic
#11
Thank you, but it still doesnt work.
Code:
		QAction *action1 = new QAction(tr("&ACTION1"), this);
		QAction *action2 = new QAction(tr("&ACTION2"), this);

		QMenu *appMenu;
		appMenu = menuBar()->addMenu(tr("MENU TITLE"));
		appMenu->addAction(action1);
		appMenu->addAction(action2);

		connect(action1, SIGNAL(triggered()), this , SLOT(doAction1()));
		connect(action2, SIGNAL(triggered()), this , SLOT(doAction2()));
 
krk969's Avatar
Posts: 754 | Thanked: 630 times | Joined on Sep 2009 @ London
#12
what doesnt work, what error do you see , could you please detail so you can solicit some responses.
__________________
Developer of :
Buddy - budget/expense manager ( website )
Showtime - a telly channel listing viewer/reminder ( website )
Travelapp - london underground status/planner ( website )
Batlevel - desktop widget for battery level ( website )

“I hear and I forget. I see and I remember. I do and I understand.”

Last edited by krk969; 2010-03-11 at 08:25.
 
Posts: 270 | Thanked: 239 times | Joined on Dec 2009 @ Czech Republic
#13
It doesnt work because I cant see any menu on the top. Any errors.
 
krk969's Avatar
Posts: 754 | Thanked: 630 times | Joined on Sep 2009 @ London
#14
is this all done in a QMainWindow ?
attach the source file if you can.
__________________
Developer of :
Buddy - budget/expense manager ( website )
Showtime - a telly channel listing viewer/reminder ( website )
Travelapp - london underground status/planner ( website )
Batlevel - desktop widget for battery level ( website )

“I hear and I forget. I see and I remember. I do and I understand.”
 
Posts: 270 | Thanked: 239 times | Joined on Dec 2009 @ Czech Republic
#15
This is full code.
Code:
class Window : public QMainWindow
{
	Q_OBJECT

public:
	Window();
};

Window::Window()
     : QMainWindow()
{
	QAction *action1 = new QAction(tr("&ACTION1"), this);
	QAction *action2 = new QAction(tr("&ACTION2"), this);

	QMenu *appMenu;
	appMenu = menuBar()->addMenu(tr("MENU TITLE"));
	appMenu->addAction(action1);
	appMenu->addAction(action2);

	connect(action1, SIGNAL(triggered()), this , SLOT(doAction1()));
	connect(action2, SIGNAL(triggered()), this , SLOT(doAction2()));

	QWidget *blank = new QWidget();
	QHBoxLayout *layout = new QHBoxLayout();
	blank->setLayout(layout);
	blank->show();
}

Window window;
 
krk969's Avatar
Posts: 754 | Thanked: 630 times | Joined on Sep 2009 @ London
#16
making corrections ...
Code:
class Window : public QMainWindow
{
Q_OBJECT

public:
Window();
};

Window::Window()
: QMainWindow()
{
QAction *action1 = new QAction(tr("&ACTION1"), this);
QAction *action2 = new QAction(tr("&ACTION2"), this);

QMenu *appMenu;
appMenu = menuBar()->addMenu(tr("MENU TITLE"));
appMenu->addAction(action1);
appMenu->addAction(action2);

connect(action1, SIGNAL(triggered()), this , SLOT(doAction1()));
connect(action2, SIGNAL(triggered()), this , SLOT(doAction2()));
 // add widgets to your main window once you have them, you dont need the below dummy blank widget.
// later you can do setCentralWidget(blank);
 
// QWidget *blank = new QWidget();
// QHBoxLayout *layout = new QHBoxLayout();
// blank->setLayout(layout);
// blank->show();
}

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
 	
Window window;
window.show();

return app.exec();
}
__________________
Developer of :
Buddy - budget/expense manager ( website )
Showtime - a telly channel listing viewer/reminder ( website )
Travelapp - london underground status/planner ( website )
Batlevel - desktop widget for battery level ( website )

“I hear and I forget. I see and I remember. I do and I understand.”

Last edited by krk969; 2010-03-24 at 22:32.
 

The Following 3 Users Say Thank You to krk969 For This Useful Post:
Posts: 270 | Thanked: 239 times | Joined on Dec 2009 @ Czech Republic
#17
Thank you. I didnt setCentraWidget.
 
Venemo's Avatar
Posts: 1,296 | Thanked: 1,773 times | Joined on Aug 2009 @ Budapest, Hungary
#18
Hi krk969!

I'm also new to Maemo and Qt.
I tried creating a window with your code. It works, but there is a side effect:

When I run the application, two menu items appear, with the name "MENU TITLE / ACTION1" and "MENU TITLE / ACTION2".
This is understandable, but what do I do if I don't want the slash signs to appear there?
 
krk969's Avatar
Posts: 754 | Thanked: 630 times | Joined on Sep 2009 @ London
#19
replace

appMenu = menuBar()->addMenu(tr("MENU TITLE"));
with
appMenu = menuBar()->addMenu(tr(""));

i dont know what i did but my previous post got replaced with this message too. but i guess you will figure it out
__________________
Developer of :
Buddy - budget/expense manager ( website )
Showtime - a telly channel listing viewer/reminder ( website )
Travelapp - london underground status/planner ( website )
Batlevel - desktop widget for battery level ( website )

“I hear and I forget. I see and I remember. I do and I understand.”
 

The Following User Says Thank You to krk969 For This Useful Post:
Venemo's Avatar
Posts: 1,296 | Thanked: 1,773 times | Joined on Aug 2009 @ Budapest, Hungary
#20
Thanks!
IT WORKS!

Now it is nice that this works from code, but is there any way in the UI designer to do this?
(I mean the UI designer of Qt Creator for Windows. I use MADDE.)

Last edited by Venemo; 2010-03-24 at 19:28.
 

The Following User Says Thank You to Venemo For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 09:27.