Beispiel #1
0
MainWindow::MainWindow()
{
    QMenu *fileMenu = new QMenu(tr("&File"));

    QAction *quitAction = fileMenu->addAction(tr("E&xit"));
    quitAction->setShortcut(tr("Ctrl+Q"));

    menuBar()->addMenu(fileMenu);

//  For convenient quoting:
//! [0]
QListWidget *listWidget = new QListWidget(this);
listWidget->setSelectionMode(QAbstractItemView::SingleSelection);
listWidget->setDragEnabled(true);
listWidget->viewport()->setAcceptDrops(true);
listWidget->setDropIndicatorShown(true);
//! [0] //! [1]
listWidget->setDragDropMode(QAbstractItemView::InternalMove);
//! [1]

    this->listWidget = listWidget;

    connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));

    setupListItems();

    setCentralWidget(listWidget);
    setWindowTitle(tr("List Widget"));
}
Beispiel #2
0
nftdialog::nftdialog(QWidget* parent, QString lang, QString templateDir) : QDialog(parent)
{
	setupUi(this);
	setModal(true);

	settings = new nftsettings(lang, templateDir);

	setWindowIcon(loadIcon("AppIcon.png"));
	
	// context menu
	removeAction = new QAction(tr("&Remove"), tnailGrid);
	openAction = new QAction(tr("&Open"), tnailGrid);
	tnailGrid->addAction(removeAction);
	tnailGrid->addAction(openAction);

	setupAbout();
	
	toolBox->setItemIcon(0, loadIcon("16/information.png"));
	toolBox->setItemIcon(1, loadIcon("16/image-x-generic.png"));
	toolBox->setItemIcon(2, loadIcon("16/help-browser.png"));
	tnailGrid->setIconSize(QSize(60, 60));
	
	// Signals and Slots Connections
	connect(categoryList, SIGNAL(itemSelectionChanged()), this, SLOT(setTNails()));
	connect(tnailGrid, SIGNAL(itemSelectionChanged()), this, SLOT(setInfo()));
	connect(tnailGrid, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(accept()));
	connect(removeAction, SIGNAL(triggered()), this, SLOT(removeTemplate()));
	connect(openAction, SIGNAL(triggered()), this, SLOT(accept()));
	
	setupListItems();
	setupCategories();
}
Beispiel #3
0
void nftdialog::removeTemplate()
{
	currentDocumentTemplate->isDeleted = true;
	textBrowser->clear();
	imageView->clear();
	currentDocumentTemplate = NULL;
	buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
	setupListItems();
	setupCategories();
	setTNails();
}
MainWindow::MainWindow()
{
    QMenu *fileMenu = new QMenu(tr("&File"));

    QAction *quitAction = fileMenu->addAction(tr("E&xit"));
    quitAction->setShortcut(tr("Ctrl+Q"));

    QMenu *itemsMenu = new QMenu(tr("&Items"));

    insertAction = itemsMenu->addAction(tr("&Insert Item"));
    removeAction = itemsMenu->addAction(tr("&Remove Item"));
    QAction *ascendingAction = itemsMenu->addAction(tr("Sort in &Ascending Order"));
    QAction *descendingAction = itemsMenu->addAction(tr("Sort in &Descending Order"));

    menuBar()->addMenu(fileMenu);
    menuBar()->addMenu(itemsMenu);

/*  For convenient quoting:
//! [0]
    QListWidget *listWidget = new QListWidget(this);
//! [0]
*/
    listWidget = new QListWidget(this);
    listWidget->setSelectionMode(QAbstractItemView::SingleSelection);

    connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
    connect(ascendingAction, SIGNAL(triggered()), this, SLOT(sortAscending()));
    connect(descendingAction, SIGNAL(triggered()), this, SLOT(sortDescending()));
    connect(insertAction, SIGNAL(triggered()), this, SLOT(insertItem()));
    connect(removeAction, SIGNAL(triggered()), this, SLOT(removeItem()));
    connect(listWidget,
            SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
            this, SLOT(updateMenus(QListWidgetItem *)));

    setupListItems();
    updateMenus(listWidget->currentItem());

    setCentralWidget(listWidget);
    setWindowTitle(tr("List Widget"));
}