Seite 1 von 2
[gelöst]context menu geht bei mir nicht.
Verfasst: 1. November 2006 21:54
von defenderLQ
hi
also ich konnte schon lang nicht mein problem mit dme context menue nicht lösen trotz paar hilfen hier im forum,
vielleicht sieht jemand der sich damit auskennt meine fehler.
DownloadsDialog.cpp:
Code: Alles auswählen
#include "rshare.h"
#include "DownloadsDialog.h"
#include "downinfo/DownInfoWindow.h"
#include <QHeaderView>
#include <QContextMenuEvent>
#include <QMenu>
#include <QCursor>
/* Images for context menu icons */
#define IMAGE_INFO ":/images/informations_16x16.png"
/** Constructor */
DownloadsDialog::DownloadsDialog(QWidget *parent)
: MainPage(parent)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
/* Hide platform specific features */
#ifdef Q_WS_WIN
#endif
}
void DownloadsDialog::contextMenuEvent(QContextMenuEvent *e)
{
//QMenu popMenu(this);
popMenu = new QMenu(this);
//popMenu.addAction(_showdowninfoAct);
//popMenu.addSeparator();
//popMenu.addAction(_resumeAct);
//popMenu.exec(e->globalPos());
popMenu->addAction(_showdowninfoAct);
popMenu->addSeparator();
//popMenu->addAction(_resumeAct);
popMenu->exec(e->globalPos());
}
void DownloadsDialog::createActions()
{
_showdowninfoAct = new QAction(QIcon(IMAGE_INFO), tr("Show Informations"), this);
connect(_showdowninfoAct, SIGNAL(triggered()), this, SLOT(showDownInfoWindow()));
// _resumeAct = new QAction(QIcon(), tr("Resume"), this);
// connect(_resumeAct, SIGNAL(triggered()), this, SLOT(close()));
}
/** Shows Downloads Informations */
void DownloadsDialog::showDownInfoWindow()
{
DownInfoWindow *downinfoWindow = new DownInfoWindow();
downinfoWindow->show();
}
DownloadsDialog.h:
Code: Alles auswählen
#ifndef _DOWNLOADSDIALOG_H
#define _DOWNLOADSDIALOG_H
#include <QFileDialog>
#include <config/rsharesettings.h>
#include "mainpage.h"
#include "ui_DownloadsDialog.h"
class DownloadsDialog : public MainPage
{
Q_OBJECT
public:
/** Default Constructor */
DownloadsDialog(QWidget *parent = 0);
/** Default Destructor */
private slots:
void showDownInfoWindow();
private:
/** Create the actions on the tray menu or menubar */
void createActions();
/** Create the context popup menu and it's submenus */
void contextMenuEvent( QContextMenuEvent *e);
/** Define the popup menus for the Context menu */
QMenu* popMenu;
/** Defines the actions for the context menu */
QAction* _showdowninfoAct;
QAction* _resumeAct;
/** Adds a new action to the toolbar. */
void addAction(QAction *action, const char *slot = 0);
/** Qt Designer generated object */
Ui::DownloadsDialog ui;
};
#endif
also habe die policy zum context menue schon alle probiert ohne erfolg bis jetzt.
Verfasst: 1. November 2006 22:14
von upsala
Kommentiere mal folgende Zeile aus:
und probier dann mal dein Context-Menü nochmal aus...
Verfasst: 1. November 2006 22:34
von defenderLQ
nein geht auch nicht!
dann verschwindet mein QTreeWidget auch im downlaodsDialog mit den dazugehörigne items.
man sieht was das ziemlich klein ist und es steht kein "Show Informations"
im Context menu.
Code: Alles auswählen
#include "rshare.h"
#include "DownloadsDialog.h"
#include "downinfo/DownInfoWindow.h"
#include <QHeaderView>
#include <QContextMenuEvent>
#include <QMenu>
#include <QCursor>
/* Images for context menu icons */
#define IMAGE_INFO ":/images/informations_16x16.png"
/** Constructor */
DownloadsDialog::DownloadsDialog(QWidget *parent)
: MainPage(parent)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
/* Hide platform specific features */
#ifdef Q_WS_WIN
#endif
}
void DownloadsDialog::contextMenuEvent(QContextMenuEvent *e)
{
popMenu = new QMenu(this);
popMenu->addAction(_showdowninfoAct);
popMenu->addSeparator();
popMenu->exec(e->globalPos());
}
void DownloadsDialog::createActions()
{
_showdowninfoAct = new QAction(QIcon(IMAGE_INFO), tr("Show Informations"), this);
connect(_showdowninfoAct, SIGNAL(triggered()), this, SLOT(showDownInfoWindow()));
}
/** Shows Downloads Informations */
void DownloadsDialog::showDownInfoWindow()
{
DownInfoWindow *downinfoWindow = new DownInfoWindow();
downinfoWindow->show();
}
Verfasst: 1. November 2006 23:11
von ChMaster
servus,
hier ein richtiger codesnipe der dich weiter bringt: (hoffe ich

)
Code: Alles auswählen
DownloadsDialog::DownloadsDialog(QWidget *parent)
: MainPage(parent)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
connect( DEIN_QTREEWIDGEWT, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( DEIN_QTREEWIDGET_POPUPMENU_REQUEST_FUNCTION( QPoint ) ) );
/* Hide platform specific features */
#ifdef Q_WS_WIN
#endif
}
Code: Alles auswählen
void DownloadsDialog::DEIN_QTREEWIDGET_POPUPMENU_REQUEST_FUNCTION( QPoint point )
{
QMenu contextMnu( this );
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
showdowninfoAct = new QAction( tr( "WAS WEIS ICH :)" ), this );
connect( showdowninfoAct , SIGNAL( triggered() ), this, SLOT( showDownInfoWindow() ) );
contextMnu.clear();
contextMnu.addAction( showdowninfoAct);
contextMnu.exec( mevent->globalPos() );
}
Verfasst: 1. November 2006 23:59
von defenderLQ
hi
ja wie muss ich mein downtreeWidget da angeben?
Code: Alles auswählen
#include "rshare.h"
#include "DownloadsDialog.h"
#include "downinfo/DownInfoWindow.h"
#include <QHeaderView>
#include <QContextMenuEvent>
#include <QMenu>
#include <QCursor>
#include <QPoint>
#include <QMouseEvent>
/* Images for context menu icons */
#define IMAGE_INFO ":/images/informations_16x16.png"
/** Constructor */
DownloadsDialog::DownloadsDialog(QWidget *parent)
: MainPage(parent)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
connect( downtreeWidget_QTREEWIDGET, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( downtreeWidget_QTREEWIDGET_POPUPMENU_REQUEST_FUNCTION( QPoint ) ) );
/* Hide platform specific features */
#ifdef Q_WS_WIN
#endif
}
void DownloadsDialog::downtreeWidget_QTREEWIDGET_POPUPMENU_REQUEST_FUNCTION( QPoint point )
{
QMenu contextMnu( this );
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
showdowninfoAct = new QAction( tr( "Show Informations" ), this );
connect( showdowninfoAct , SIGNAL( triggered() ), this, SLOT( showDownInfoWindow() ) );
contextMnu.clear();
contextMnu.addAction( showdowninfoAct);
contextMnu.exec( mevent->globalPos() );
}
void DownloadsDialog::createActions()
{
//showdowninfoAct = new QAction(QIcon(IMAGE_INFO), tr("Show Informations"), this);
//connect(showdowninfoAct, SIGNAL(triggered()), this, SLOT(showDownInfoWindow()));
}
/** Shows Downloads Informations */
void DownloadsDialog::showDownInfoWindow()
{
DownInfoWindow *downinfoWindow = new DownInfoWindow();
downinfoWindow->show();
}
<widget class="QTreeWidget" name="downtreeWidget" >
Verfasst: 2. November 2006 00:03
von defenderLQ
ups habe was vergessen aus lauter eile:
Code: Alles auswählen
#ifndef _DOWNLOADSDIALOG_H
#define _DOWNLOADSDIALOG_H
#include <QFileDialog>
#include <config/rsharesettings.h>
#include "mainpage.h"
#include "ui_DownloadsDialog.h"
class DownloadsDialog : public MainPage
{
Q_OBJECT
public:
/** Default Constructor */
DownloadsDialog(QWidget *parent = 0);
/** Default Destructor */
private slots:
void showDownInfoWindow();
private:
/** Create the actions on the tray menu or menubar */
void createActions();
/** Create the context popup menu and it's submenus */
void downtreeWidget_QTREEWIDGET_POPUPMENU_REQUEST_FUNCTION( QPoint point );
/** Define the popup menus for the Context menu */
QMenu* contextMnu;
/** Defines the actions for the context menu */
QAction* showdowninfoAct;
QAction* _resumeAct;
QTreeWidget* downtreeWidget_QTREEWIDGET;
/** Adds a new action to the toolbar. */
void addAction(QAction *action, const char *slot = 0);
/** Qt Designer generated object */
Ui::DownloadsDialog ui;
};
#endif
nun wie muss ich downtreewidget einfach ins puplic rein in .h ?
nach erfolgreichem kompilieren gehts immer noch nicht.
Verfasst: 2. November 2006 17:14
von upsala
Pack doch einfach mal dein Projekt in eine Zip-Datei uns stell sie hier rein...
Verfasst: 2. November 2006 22:24
von defenderLQ
ja das mit dem context menu hab ich schon seit anfang meines projects nicht in griff.
also seit august versuche ich schon verschiedene methoden versucht.
Verfasst: 2. November 2006 22:32
von ChMaster
past, habe den xaceplus extractor

ich schau es mir jetzt mal an und gebe dir dann die geänderten dateien
zurück.
Verfasst: 2. November 2006 22:55
von -Marco-
defenderLQ hat geschrieben:ja das mit dem context menu hab ich schon seit anfang meines projects nicht in griff.
hast du in deinen Projekt auch
virtual deklariert?
In den geposteten Sachen kann ich das nicht finden.
Verfasst: 2. November 2006 23:02
von defenderLQ
also ich hab das schon rausgschmissen weil es nicht ging und hier jemand mir anders vorgeschlagen hat.
mein sources mit contextmenuevent:
Downloadsdialog.cpp:
Code: Alles auswählen
#include "rshare.h"
#include "DownloadsDialog.h"
#include "downinfo/DownInfoWindow.h"
#include <QHeaderView>
#include <QContextMenuEvent>
#include <QMenu>
#include <QCursor>
/* Images for context menu icons */
#define IMAGE_INFO ":/images/informations_16x16.png"
/** Constructor */
DownloadsDialog::DownloadsDialog(QWidget *parent)
: MainPage(parent)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
/* Hide platform specific features */
#ifdef Q_WS_WIN
#endif
}
void DownloadsDialog::contextMenuEvent(QContextMenuEvent *e)
{
popMenu = new QMenu(this);
popMenu->addAction(_showdowninfoAct);
popMenu->addSeparator();
popMenu->exec(e->globalPos());
}
void DownloadsDialog::createActions()
{
_showdowninfoAct = new QAction(QIcon(IMAGE_INFO), tr("Show Informations"), this);
connect(_showdowninfoAct, SIGNAL(triggered()), this, SLOT(showDownInfoWindow()));
}
/** Shows Downloads Informations */
void DownloadsDialog::showDownInfoWindow()
{
DownInfoWindow *downinfoWindow = new DownInfoWindow();
downinfoWindow->show();
}
downlaodsdialog.h
Code: Alles auswählen
#ifndef _DOWNLOADSDIALOG_H
#define _DOWNLOADSDIALOG_H
#include <QFileDialog>
#include <config/rsharesettings.h>
#include "mainpage.h"
#include "ui_DownloadsDialog.h"
class DownloadsDialog : public MainPage
{
Q_OBJECT
public:
/** Default Constructor */
DownloadsDialog(QWidget *parent = 0);
/** Default Destructor */
private slots:
void showDownInfoWindow();
private:
/** Create the actions on the tray menu or menubar */
void createActions();
/** Create the context popup menu and it's submenus */
void contextMenuEvent( QContextMenuEvent *e);
/** Define the popup menus for the Context menu */
QMenu* popMenu;
/** Defines the actions for the context menu */
QAction* _showdowninfoAct;
QAction* _resumeAct;
/** Adds a new action to the toolbar. */
void addAction(QAction *action, const char *slot = 0);
/** Qt Designer generated object */
Ui::DownloadsDialog ui;
};
#endif
oder hängt das von den stackedwidget ab?
da habe ich im Mainwindow auch zu custom geändert wegen contextmenu hat auch nichts gebracht.
Downloadsdialog ist ein Stackedwidget von mainwindow.
habe zu .ace gepackt weil das weniger ist als mit zip.
mit .zip wäre es zu groß als atachment.
Verfasst: 2. November 2006 23:08
von -Marco-
statt
nimm
BTW: wenn einige Sachen nicht auf Anhieb funktionieren, bau ich mir immer ein kleines Testprojekt.
Verfasst: 2. November 2006 23:15
von ChMaster
man ihr siet mir zu schnell

HEADER
Code: Alles auswählen
#ifndef _DOWNLOADSDIALOG_H
#define _DOWNLOADSDIALOG_H
#include <QFileDialog>
//#include <config/rsharesettings.h>
#include "mainpage.h"
#include "ui_DownloadsDialog.h"
class DownloadsDialog : public MainPage
{
Q_OBJECT
public:
/** Default Constructor */
DownloadsDialog(QWidget *parent = 0);
/** Default Destructor */
private slots:
void showDownInfoWindow();
/** Create the context popup menu and it's submenus */
void downtreeWidgetCostumPopupMenu( QPoint point );
private:
/** Create the actions on the tray menu or menubar */
void createActions();
void insertTransfers();
/** Define the popup menus for the Context menu */
QMenu* contextMnu;
/** Defines the actions for the context menu */
QAction* showdowninfoAct;
QAction* _resumeAct;
QTreeWidget *downtreeWidget;
/** Adds a new action to the toolbar. */
void addAction(QAction *action, const char *slot = 0);
/** Qt Designer generated object */
Ui::DownloadsDialog ui;
};
#endif
CPP
Code: Alles auswählen
#include "rshare.h"
#include "DownloadsDialog.h"
#include "downinfo/DownInfoWindow.h"
#include <QHeaderView>
#include <QContextMenuEvent>
#include <QMenu>
#include <QCursor>
#include <QPoint>
#include <QMouseEvent>
#include "rsiface/rsiface.h"
/* Images for context menu icons */
#define IMAGE_INFO ":/images/informations_16x16.png"
/** Constructor */
DownloadsDialog::DownloadsDialog(QWidget *parent)
: MainPage(parent)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
insertTransfers();
connect( ui.downtreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( downtreeWidgetCostumPopupMenu( QPoint ) ) );
/* Hide platform specific features */
#ifdef Q_WS_WIN
#endif
}
void DownloadsDialog::downtreeWidgetCostumPopupMenu( QPoint point )
{
QMenu contextMnu( this );
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
showdowninfoAct = new QAction( tr( "Show Informations" ), this );
connect( showdowninfoAct , SIGNAL( triggered() ), this, SLOT( showDownInfoWindow() ) );
contextMnu.clear();
contextMnu.addAction( showdowninfoAct);
contextMnu.exec( mevent->globalPos() );
}
/** Shows Downloads Informations */
void DownloadsDialog::showDownInfoWindow()
{
DownInfoWindow *downinfoWindow = new DownInfoWindow();
downinfoWindow->show();
}
downtreeWidgetCostumPopupMenu(...) gehört in den
slots block.
private slots:
void downtreeWidgetCostumPopupMenu( QPoint point );
so müsste es funtionieren.
Verfasst: 2. November 2006 23:16
von defenderLQ
es hat nichts gebracht ! leider.
geht immer noch nicht..
Verfasst: 2. November 2006 23:20
von ChMaster
includier mal #include <QTreeWidget>
da ich es nicht seh .... in den sourcen ....